Skip to content

Commit c5063b4

Browse files
committed
check to make sure source file exists
1 parent 49304a9 commit c5063b4

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0-develop3
1+
1.0.0-develop4

plex_image_cleanup.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,22 @@ def get_resources(media):
249249
local_path = Path(meta_dirs[item.type]) / guid_hash[0] / f"{guid_hash[1:]}.bundle" / "Uploads" / resource_path
250250
source_path = meta_dir / local_path
251251

252-
section_images += 1
253-
total_size += source_path.stat().st_size
254-
if mode == "move":
255-
destination_path = restore_dir / local_path.with_suffix(".jpg")
256-
msg = f"MOVE: {source_path} --> {destination_path}"
257-
destination_path.parent.mkdir(parents=True, exist_ok=True)
258-
source_path.rename(destination_path)
259-
elif mode == "remove":
260-
msg = f"REMOVE: {source_path}"
261-
source_path.unlink()
252+
if source_path.exists():
253+
section_images += 1
254+
total_size += source_path.stat().st_size
255+
if mode == "move":
256+
destination_path = restore_dir / local_path.with_suffix(".jpg")
257+
msg = f"MOVE: {source_path} --> {destination_path}"
258+
destination_path.parent.mkdir(parents=True, exist_ok=True)
259+
source_path.rename(destination_path)
260+
elif mode == "remove":
261+
msg = f"REMOVE: {source_path}"
262+
source_path.unlink()
263+
else:
264+
msg = f"BLOAT FILE: {source_path}"
262265
else:
263-
msg = f"BLOAT FILE: {source_path}"
266+
msg = f"BLOAT FILE NOT FOUND: {source_path}"
267+
264268
if mode == "report":
265269
logger.debug(msg)
266270
else:

0 commit comments

Comments
 (0)