Skip to content

Commit

Permalink
check to make sure source file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
meisnate12 committed Aug 17, 2023
1 parent 49304a9 commit c5063b4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0-develop3
1.0.0-develop4
26 changes: 15 additions & 11 deletions plex_image_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,22 @@ def get_resources(media):
local_path = Path(meta_dirs[item.type]) / guid_hash[0] / f"{guid_hash[1:]}.bundle" / "Uploads" / resource_path
source_path = meta_dir / local_path

section_images += 1
total_size += source_path.stat().st_size
if mode == "move":
destination_path = restore_dir / local_path.with_suffix(".jpg")
msg = f"MOVE: {source_path} --> {destination_path}"
destination_path.parent.mkdir(parents=True, exist_ok=True)
source_path.rename(destination_path)
elif mode == "remove":
msg = f"REMOVE: {source_path}"
source_path.unlink()
if source_path.exists():
section_images += 1
total_size += source_path.stat().st_size
if mode == "move":
destination_path = restore_dir / local_path.with_suffix(".jpg")
msg = f"MOVE: {source_path} --> {destination_path}"
destination_path.parent.mkdir(parents=True, exist_ok=True)
source_path.rename(destination_path)
elif mode == "remove":
msg = f"REMOVE: {source_path}"
source_path.unlink()
else:
msg = f"BLOAT FILE: {source_path}"
else:
msg = f"BLOAT FILE: {source_path}"
msg = f"BLOAT FILE NOT FOUND: {source_path}"

if mode == "report":
logger.debug(msg)
else:
Expand Down

0 comments on commit c5063b4

Please sign in to comment.