mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Fix when the cache from jobs is saved into DB + sleep 5 seconds when waiting for the database for the UI
This commit is contained in:
parent
d32102376f
commit
f1a868c66b
2 changed files with 5 additions and 6 deletions
|
|
@ -4,7 +4,6 @@ from hashlib import sha512
|
|||
from inspect import getsourcefile
|
||||
from json import dumps, loads
|
||||
from pathlib import Path
|
||||
from shutil import copy
|
||||
from sys import _getframe
|
||||
from threading import Lock
|
||||
from traceback import format_exc
|
||||
|
|
@ -27,7 +26,7 @@ def is_cached_file(file: str, expire: str, db=None) -> bool:
|
|||
if not db:
|
||||
return False
|
||||
cached_file = db.get_job_cache_file(
|
||||
getsourcefile(_getframe(1)).replace(".py", ""),
|
||||
getsourcefile(_getframe(1)).replace(".py", "").split("/")[-1],
|
||||
file.split("/")[-1],
|
||||
with_data=False,
|
||||
)
|
||||
|
|
@ -69,7 +68,7 @@ def cache_hash(cache: str, db=None) -> Optional[str]:
|
|||
return loads(Path(f"{cache}.md").read_text()).get("checksum", None)
|
||||
if db:
|
||||
cached_file = db.get_job_cache_file(
|
||||
getsourcefile(_getframe(1)).replace(".py", ""),
|
||||
getsourcefile(_getframe(1)).replace(".py", "").split("/")[-1],
|
||||
cache.split("/")[-1],
|
||||
with_data=False,
|
||||
)
|
||||
|
|
@ -93,7 +92,7 @@ def cache_file(
|
|||
if db:
|
||||
with lock:
|
||||
err = db.update_job_cache(
|
||||
getsourcefile(_getframe(1)).replace(".py", ""),
|
||||
getsourcefile(_getframe(1)).replace(".py", "").split("/")[-1],
|
||||
service_id,
|
||||
cache.split("/")[-1],
|
||||
content,
|
||||
|
|
|
|||
|
|
@ -28,14 +28,14 @@ class Config:
|
|||
self.__logger.warning(
|
||||
"Database is not initialized, retrying in 5s ...",
|
||||
)
|
||||
sleep(3)
|
||||
sleep(5)
|
||||
|
||||
env = self.__db.get_config()
|
||||
while not self.__db.is_first_config_saved() or not env:
|
||||
self.__logger.warning(
|
||||
"Database doesn't have any config saved yet, retrying in 5s ...",
|
||||
)
|
||||
sleep(3)
|
||||
sleep(5)
|
||||
env = self.__db.get_config()
|
||||
|
||||
self.__logger.info("Database is ready")
|
||||
|
|
|
|||
Loading…
Reference in a new issue