fixing path and hashing?! maybe

This commit is contained in:
flipnism
2023-09-11 10:33:30 +07:00
parent c2b5e23e61
commit fe7e4590d4
2 changed files with 22 additions and 14 deletions
+17 -10
View File
@@ -5,25 +5,32 @@ import hashlib
comfy_path = os.path.dirname(folder_paths.__file__)
js_path = os.path.join(comfy_path, "web")
def sha256sum(filename):
with open(filename, 'rb', buffering=0) as f:
return hashlib.file_digest(f, 'sha256').hexdigest()
def need_update():
return sha256sum('user.css')!=sha256sum(os.path.join(js_path,'user.css'))
def hash_file(filename: str, blocksize: int = 4096) -> str:
hsh = hashlib.md5()
with open(filename, "rb") as f:
while True:
buf = f.read(blocksize)
if not buf:
break
hsh.update(buf)
return hsh.hexdigest()
def need_update():
return hash_file(os.path.join(os.path.dirname(__file__), "user.css")) != hash_file(
os.path.join(js_path, "user.css")
)
cur_css = ""
if need_update():
print('updating user.css')
print("updating user.css")
with open(os.path.join(os.path.dirname(__file__), "user.css")) as file:
cur_css = file.read()
with open(os.path.join(js_path, "user.css"), "w") as f:
f.write(cur_css)
WEB_DIRECTORY = "./web"
NODE_CLASS_MAPPINGS = {}
+1
View File
@@ -26,6 +26,7 @@ thead {
}
.comfy-menu {
z-index: 1;
}
.comfy-menu,
.comfy-modal {