Ver código fonte

Adding milliseconds precision on FileConverter.hx cache filled on js platform.

clementlandrin 10 meses atrás
pai
commit
ea454d882c
1 arquivos alterados com 12 adições e 3 exclusões
  1. 12 3
      hxd/fs/FileConverter.hx

+ 12 - 3
hxd/fs/FileConverter.hx

@@ -35,7 +35,7 @@ class FileConverter {
 	var tmpDir : String;
 	var configs : Map<String,ConvertConfig> = new Map();
 	var defaultConfig : ConvertConfig;
-	var cache : Map<String,Array<{ out : String, time : Int, hash : String, ver : Null<Int> }>>;
+	var cache : Map<String,Array<{ out : String, time : Int, hash : String, ver : Null<Int>, milliseconds : Null<Int> }>>;
 	var cacheTime : Float;
 
 	static var extraConfigs:Array<Dynamic> = [];
@@ -306,6 +306,7 @@ class FileConverter {
 				time : 0,
 				hash : "",
 				ver: conv.version,
+				milliseconds : #if js 0 #else null #end
 			};
 			entry.push(match);
 		}
@@ -314,16 +315,23 @@ class FileConverter {
 
 		if( !sys.FileSystem.exists(fullPath) ) throw "Missing "+fullPath;
 
-		var time = std.Math.floor(getFileTime(fullPath) / FILE_TIME_PRECISION);
+		var fileTime = getFileTime(fullPath);
+		var time = std.Math.floor(fileTime / FILE_TIME_PRECISION);
+		#if js
+		var milliseconds = std.Math.floor(fileTime) - time * FILE_TIME_PRECISION;
+		#else
+		var milliseconds = null;
+		#end
 		var alreadyGen = sys.FileSystem.exists(fullOutPath) && match.ver == conv.version #if disable_res_cache && false #end;
 
-		if( alreadyGen && match.time == time )
+		if( alreadyGen && match.time == time #if js && (match.milliseconds == null || match.milliseconds == milliseconds ) #end )
 			return; // not changed (time stamp)
 
 		var content = hxd.File.getBytes(fullPath);
 		var hash = haxe.crypto.Sha1.make(content).toHex();
 		if( alreadyGen && match.hash == hash ) {
 			match.time = time;
+			match.milliseconds = milliseconds;
 			saveCache();
 			return; // not changed (hash)
 		}
@@ -349,6 +357,7 @@ class FileConverter {
 
 		match.ver = conv.version;
 		match.time = time;
+		match.milliseconds = milliseconds;
 		match.hash = hash;
 		saveCache();
 	}