fix(musicseerr): implement thread-safe jobs saving with a write lock and unique temp files
Build and Push Docker Images / build (api) (push) Successful in 1m11s
Details
Build and Push Docker Images / build (musicseerr) (push) Successful in 8m2s
Details
Build and Push Docker Images / build (web) (push) Successful in 3m1s
Details
Build and Push Docker Images / build (nextgen) (push) Successful in 12m41s
Details
Build and Push Docker Images / build (worker) (push) Successful in 14m30s
Details
Build and Push Docker Images / deploy (push) Successful in 14s
Details
Build and Push Docker Images / build (api) (push) Successful in 1m11s
Details
Build and Push Docker Images / build (musicseerr) (push) Successful in 8m2s
Details
Build and Push Docker Images / build (web) (push) Successful in 3m1s
Details
Build and Push Docker Images / build (nextgen) (push) Successful in 12m41s
Details
Build and Push Docker Images / build (worker) (push) Successful in 14m30s
Details
Build and Push Docker Images / deploy (push) Successful in 14s
Details
This commit is contained in:
parent
a1b6fd8011
commit
e0ba21eb07
|
|
@ -19,15 +19,19 @@ import json
|
|||
|
||||
JOBS_FILE = "/remote-music/.musicseerr_jobs.json"
|
||||
|
||||
from tasks import JOBS_WRITE_LOCK
|
||||
|
||||
def save_jobs_db(jobs_dict):
|
||||
with JOBS_WRITE_LOCK:
|
||||
try:
|
||||
temp_file = JOBS_FILE + ".tmp"
|
||||
temp_file = f"{JOBS_FILE}.{uuid.uuid4()}.tmp"
|
||||
with open(temp_file, "w") as f:
|
||||
json.dump(jobs_dict, f, indent=2)
|
||||
os.replace(temp_file, JOBS_FILE)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to save jobs database: {e}")
|
||||
|
||||
|
||||
def load_jobs_db():
|
||||
if os.path.exists(JOBS_FILE):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -20,15 +20,20 @@ logger = logging.getLogger("musicseerr-tasks")
|
|||
|
||||
JOBS_FILE = "/remote-music/.musicseerr_jobs.json"
|
||||
|
||||
JOBS_WRITE_LOCK = threading.Lock()
|
||||
|
||||
def save_jobs(jobs_dict):
|
||||
with JOBS_WRITE_LOCK:
|
||||
try:
|
||||
temp_file = JOBS_FILE + ".tmp"
|
||||
import uuid
|
||||
temp_file = f"{JOBS_FILE}.{uuid.uuid4()}.tmp"
|
||||
with open(temp_file, "w") as f:
|
||||
json.dump(jobs_dict, f, indent=2)
|
||||
os.replace(temp_file, JOBS_FILE)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to save jobs database: {e}")
|
||||
|
||||
|
||||
def move_new_files_to_dest(temp_dir: str, dest_dir: str) -> list:
|
||||
moved = []
|
||||
if not os.path.exists(temp_dir):
|
||||
|
|
|
|||
Loading…
Reference in New Issue