aboutsummaryrefslogtreecommitdiffstats
path: root/modules/cache.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-08-24 08:09:04 +0000
committerAUTOMATIC1111 <16777216c@gmail.com>2023-08-24 08:09:04 +0000
commit189229bbf9276fb73e48c783856b02fc57ab5c9b (patch)
tree728b1ab97fec6d18a1ec687ba552ca83b0dcf109 /modules/cache.py
parent31f2be3dcedf85c036c5f784c640208d122b62ed (diff)
parentb6c02174050b2c5dd98bf24c797e85ff269516f5 (diff)
downloadstable-diffusion-webui-gfx803-189229bbf9276fb73e48c783856b02fc57ab5c9b.tar.gz
stable-diffusion-webui-gfx803-189229bbf9276fb73e48c783856b02fc57ab5c9b.tar.bz2
stable-diffusion-webui-gfx803-189229bbf9276fb73e48c783856b02fc57ab5c9b.zip
Merge branch 'dev' into release_candidate
Diffstat (limited to 'modules/cache.py')
-rw-r--r--modules/cache.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/cache.py b/modules/cache.py
index 71fe6302..ff26a213 100644
--- a/modules/cache.py
+++ b/modules/cache.py
@@ -1,11 +1,12 @@
import json
+import os
import os.path
import threading
import time
from modules.paths import data_path, script_path
-cache_filename = os.path.join(data_path, "cache.json")
+cache_filename = os.environ.get('SD_WEBUI_CACHE_FILE', os.path.join(data_path, "cache.json"))
cache_data = None
cache_lock = threading.Lock()
@@ -29,9 +30,12 @@ def dump_cache():
time.sleep(1)
with cache_lock:
- with open(cache_filename, "w", encoding="utf8") as file:
+ cache_filename_tmp = cache_filename + "-"
+ with open(cache_filename_tmp, "w", encoding="utf8") as file:
json.dump(cache_data, file, indent=4)
+ os.replace(cache_filename_tmp, cache_filename)
+
dump_cache_after = None
dump_cache_thread = None