diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-07-15 06:20:43 +0000 |
---|---|---|
committer | AUTOMATIC1111 <16777216c@gmail.com> | 2023-07-15 06:20:43 +0000 |
commit | 510e5fc8c60dd6278d0bc52effc23257c717dc1b (patch) | |
tree | c582a23c99258c16eec973e11bc09b9677642b36 /modules/hashes.py | |
parent | 2b1bae0d755c2d5201f6a6aadeadb5588208d43f (diff) | |
download | stable-diffusion-webui-gfx803-510e5fc8c60dd6278d0bc52effc23257c717dc1b.tar.gz stable-diffusion-webui-gfx803-510e5fc8c60dd6278d0bc52effc23257c717dc1b.tar.bz2 stable-diffusion-webui-gfx803-510e5fc8c60dd6278d0bc52effc23257c717dc1b.zip |
cache git extension repo information
Diffstat (limited to 'modules/hashes.py')
-rw-r--r-- | modules/hashes.py | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/modules/hashes.py b/modules/hashes.py index ec1187fe..b7a33b42 100644 --- a/modules/hashes.py +++ b/modules/hashes.py @@ -1,43 +1,11 @@ import hashlib
-import json
import os.path
-import filelock
-
from modules import shared
-from modules.paths import data_path, script_path
-
-
-cache_filename = os.path.join(data_path, "cache.json")
-cache_data = None
-
-
-def dump_cache():
- with filelock.FileLock(f"{cache_filename}.lock"):
- with open(cache_filename, "w", encoding="utf8") as file:
- json.dump(cache_data, file, indent=4)
-
-
-def cache(subsection):
- global cache_data
-
- if cache_data is None:
- with filelock.FileLock(f"{cache_filename}.lock"):
- if not os.path.isfile(cache_filename):
- cache_data = {}
- else:
- try:
- with open(cache_filename, "r", encoding="utf8") as file:
- cache_data = json.load(file)
- except Exception:
- os.replace(cache_filename, os.path.join(script_path, "tmp", "cache.json"))
- print('[ERROR] issue occurred while trying to read cache.json, move current cache to tmp/cache.json and create new cache')
- cache_data = {}
-
- s = cache_data.get(subsection, {})
- cache_data[subsection] = s
+import modules.cache
- return s
+dump_cache = modules.cache.dump_cache
+cache = modules.cache.cache
def calculate_sha256(filename):
|