Browse Source

added LFS.clearCache on domkit.Style refresh (prevent not found file to persist)

Nicolas Cannasse 6 years ago
parent
commit
3f3bbc0bb1
2 changed files with 12 additions and 1 deletions
  1. 5 1
      h2d/domkit/Style.hx
  2. 7 0
      hxd/fs/LocalFileSystem.hx

+ 5 - 1
h2d/domkit/Style.hx

@@ -12,7 +12,11 @@ class Style extends domkit.CssStyle {
 	}
 	}
 
 
 	public function load( r : hxd.res.Resource ) {
 	public function load( r : hxd.res.Resource ) {
-		r.watch(function() onChange());
+		r.watch(function() {
+			var fs = hxd.impl.Api.downcast(hxd.res.Loader.currentInstance.fs, hxd.fs.LocalFileSystem);
+			if( fs != null ) fs.clearCache();
+			onChange();
+		});
 		resources.push(r);
 		resources.push(r);
 		add(new domkit.CssParser().parseSheet(r.entry.getText()));
 		add(new domkit.CssParser().parseSheet(r.entry.getText()));
 		for( o in currentObjects )
 		for( o in currentObjects )

+ 7 - 0
hxd/fs/LocalFileSystem.hx

@@ -271,6 +271,13 @@ class LocalFileSystem implements FileSystem {
 		return e;
 		return e;
 	}
 	}
 
 
+	public function clearCache() {
+		for( path in fileCache.keys() ) {
+			var r = fileCache.get(path);
+			if( r.r == null ) fileCache.remove(path);
+		}
+	}
+
 	public function exists( path : String ) {
 	public function exists( path : String ) {
 		var f = open(path);
 		var f = open(path);
 		return f != null;
 		return f != null;