Skip to content

Commit fe7e459

Browse files
committed
fixing path and hashing?! maybe
1 parent c2b5e23 commit fe7e459

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

__init__.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,32 @@
55
comfy_path = os.path.dirname(folder_paths.__file__)
66
js_path = os.path.join(comfy_path, "web")
77

8-
def sha256sum(filename):
9-
with open(filename, 'rb', buffering=0) as f:
10-
return hashlib.file_digest(f, 'sha256').hexdigest()
11-
def need_update():
12-
return sha256sum('user.css')!=sha256sum(os.path.join(js_path,'user.css'))
13-
148

15-
16-
cur_css = ""
17-
if need_update():
18-
print('updating user.css')
19-
with open(os.path.join(os.path.dirname(__file__), "user.css")) as file:
20-
cur_css = file.read()
21-
with open(os.path.join(js_path, "user.css"), "w") as f:
22-
f.write(cur_css)
9+
def hash_file(filename: str, blocksize: int = 4096) -> str:
10+
hsh = hashlib.md5()
11+
with open(filename, "rb") as f:
12+
while True:
13+
buf = f.read(blocksize)
14+
if not buf:
15+
break
16+
hsh.update(buf)
17+
return hsh.hexdigest()
2318

2419

20+
def need_update():
21+
return hash_file(os.path.join(os.path.dirname(__file__), "user.css")) != hash_file(
22+
os.path.join(js_path, "user.css")
23+
)
2524

2625

26+
cur_css = ""
27+
if need_update():
28+
print("updating user.css")
29+
with open(os.path.join(os.path.dirname(__file__), "user.css")) as file:
30+
cur_css = file.read()
31+
with open(os.path.join(js_path, "user.css"), "w") as f:
32+
f.write(cur_css)
2733

2834

2935
WEB_DIRECTORY = "./web"
36+
NODE_CLASS_MAPPINGS = {}

user.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ thead {
2626
}
2727
.comfy-menu {
2828
z-index: 1;
29+
2930
}
3031
.comfy-menu,
3132
.comfy-modal {

0 commit comments

Comments
 (0)