mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-03-23 08:38:22 +03:00
Compare commits
2 Commits
f1a19128ed
...
594a706347
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
594a706347 | ||
|
|
e5fec56893 |
@ -98,7 +98,6 @@ def sync_recordings(
|
||||
{"id": recording.id, "path": recording.path}
|
||||
)
|
||||
|
||||
result.files_checked += recordings_count
|
||||
result.orphans_found += len(recordings_to_delete)
|
||||
result.orphan_paths.extend(
|
||||
[
|
||||
@ -173,7 +172,7 @@ def sync_recordings(
|
||||
for file in files
|
||||
}
|
||||
|
||||
result.files_checked += len(files_on_disk)
|
||||
result.files_checked = len(files_on_disk)
|
||||
|
||||
files_to_delete: list[str] = []
|
||||
for file in files_on_disk:
|
||||
@ -198,16 +197,20 @@ def sync_recordings(
|
||||
result.aborted = True
|
||||
return result
|
||||
|
||||
if files_to_delete and not dry_run:
|
||||
if dry_run:
|
||||
logger.info(
|
||||
f"Deleting {len(files_to_delete)} recordings files with missing DB entries"
|
||||
f"Recordings sync (dry run): Found {len(files_to_delete)} orphaned files"
|
||||
)
|
||||
for file in files_to_delete:
|
||||
try:
|
||||
os.unlink(file)
|
||||
result.orphans_deleted += 1
|
||||
except OSError as e:
|
||||
logger.error(f"Failed to delete {file}: {e}")
|
||||
return result
|
||||
|
||||
# Delete orphans
|
||||
logger.info(f"Deleting {len(files_to_delete)} orphaned recordings files")
|
||||
for file in files_to_delete:
|
||||
try:
|
||||
os.unlink(file)
|
||||
result.orphans_deleted += 1
|
||||
except OSError as e:
|
||||
logger.error(f"Failed to delete {file}: {e}")
|
||||
|
||||
logger.debug("End sync recordings.")
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user