mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-04 19:11:14 +03:00
Refactor move_preview_frames function (#23264)
Some checks are pending
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
Some checks are pending
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
Refactor move_preview_frames to simplify logic and improve error handling.
This commit is contained in:
parent
8ea46e7c6c
commit
a576ad5218
@ -342,20 +342,30 @@ def move_preview_frames(loc: str) -> None:
|
|||||||
preview_holdover = os.path.join(CLIPS_DIR, "preview_restart_cache")
|
preview_holdover = os.path.join(CLIPS_DIR, "preview_restart_cache")
|
||||||
preview_cache = os.path.join(CACHE_DIR, "preview_frames")
|
preview_cache = os.path.join(CACHE_DIR, "preview_frames")
|
||||||
|
|
||||||
|
if loc == "clips":
|
||||||
|
src = preview_cache
|
||||||
|
dst = preview_holdover
|
||||||
|
elif loc == "cache":
|
||||||
|
src = preview_holdover
|
||||||
|
dst = preview_cache
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if loc == "clips":
|
if not os.path.exists(src):
|
||||||
shutil.move(preview_cache, preview_holdover)
|
return
|
||||||
elif loc == "cache":
|
|
||||||
if not os.path.exists(preview_holdover):
|
|
||||||
return
|
|
||||||
|
|
||||||
if not os.access(preview_holdover, os.R_OK | os.W_OK):
|
shutil.move(src, dst)
|
||||||
logger.error(
|
|
||||||
"Insufficient permissions on preview restart cache at %s",
|
|
||||||
preview_holdover,
|
|
||||||
)
|
|
||||||
return
|
|
||||||
|
|
||||||
shutil.move(preview_holdover, preview_cache)
|
except PermissionError:
|
||||||
|
logger.error(
|
||||||
|
"Insufficient permissions while moving preview restart cache from %s to %s",
|
||||||
|
src,
|
||||||
|
dst,
|
||||||
|
)
|
||||||
except shutil.Error:
|
except shutil.Error:
|
||||||
logger.error("Failed to restore preview cache.")
|
logger.error(
|
||||||
|
"Failed to move preview restart cache from %s to %s",
|
||||||
|
src,
|
||||||
|
dst,
|
||||||
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user