Improve assets cache break, allow disabling, or forcing a specific cache version

This commit is contained in:
Joshua Granick
2019-01-04 14:29:31 -08:00
parent ac84c458f1
commit 0557e64a4d
2 changed files with 19 additions and 12 deletions

View File

@@ -1,13 +1,14 @@
package lime.utils;
import haxe.macro.Compiler;
import lime.media.AudioBuffer;
import lime.graphics.Image;
#if !(macro || commonjs)
import lime._internal.macros.AssetsMacro;
#end
import lime.media.AudioBuffer;
import lime.graphics.Image;
#if !lime_debug
@:fileXml('tags="haxe,release"')
@:noDebug
@@ -29,7 +30,14 @@ class AssetCache {
audio = new Map<String, AudioBuffer> ();
font = new Map<String, Dynamic /*Font*/> ();
image = new Map<String, Image> ();
version = #if (macro || commonjs) 0 #else AssetsMacro.cacheVersion () #end;
#if (macro || commonjs || lime_disable_assets_version)
version = 0;
#elseif lime_assets_version
version = Std.parseInt (Compiler.getDefine ("lime-assets-version"));
#else
version = AssetsMacro.cacheVersion ();
#end
}

View File

@@ -617,15 +617,14 @@ class Assets {
@:noCompletion private static function __cacheBreak (path:String):String {
#if web
if (cache.version > 0) {
if (path.indexOf ("?") > -1) {
path += "&" + cache.version;
} else {
path += "?" + cache.version;
}
}
#end
return path;