New Command - Remove old JPG from PhotoTranscode

This commit is contained in:
ChuckPa
2024-01-13 00:02:16 -05:00
parent 8863beeab2
commit 61dc716e65

View File

@@ -2,12 +2,12 @@
#########################################################################
# Plex Media Server database check and repair utility script. #
# Maintainer: ChuckPa #
# Version: v1.02.01 #
# Date: 12-Jan-2024 #
# Version: v1.02.99 #
# Date: 14-Jan-2024 #
#########################################################################
# Version for display purposes
Version="v1.02.01"
Version="v1.02.99"
# Flag when temp files are to be retained
Retain=0
@@ -1487,6 +1487,41 @@ DownloadAndUpdate() {
return 1
}
# Remove old jpg files from the PhotoTranscoder directory (> 30 days)
DoRemovePhotoTranscoder() {
TransCacheDir="$AppSuppDir/Plex Media Server/Cache/PhotoTranscoder"
RemoveIt=0
# If scripted / command line options, clean automatically
if [ $Scripted -eq 1 ]; then
RemoveIt=1
else
Output "Counting how many files are more than 30 days old."
FileCount=$(find "$TransCacheDir" -name \*.jpg -mtime +30 -print | wc -l)
# If nothing found, continue back to the menu
if [ $FileCount -eq 0 ]; then
Output "No files found to remove."
continue
else
# Ask if we should remove it
if ConfirmYesNo "OK to remove $FileCount files? "; then
RemoveIt=1
fi
fi
fi
# Remove the jpgs ?
if [ $RemoveIt -eq 1 ]; then
Output "Removal started."
find "$TransCacheDir" -name \*.jpg -mtime +30 -exec rm -f {} \;
Output "Removal completed."
fi
}
#############################################################
# Main utility begins here #
#############################################################
@@ -1624,7 +1659,8 @@ do
echo " 9 - 'replace' - Replace current databases with newest usable backup copy (interactive)."
echo " 10 - 'show' - Show logfile."
echo " 11 - 'status' - Report status of PMS (run-state and databases)."
echo " 12 - 'undo' - Undo last successful command."
echo " 12 - 'remove' - Remove old jpg files from PhotoTranscoder cache."
echo " 13 - 'undo' - Undo last successful command."
echo ""
[ $IgnoreErrors -eq 0 ] && echo " 42 - 'ignore' - Ignore duplicate/constraint errors."
@@ -1927,8 +1963,24 @@ do
;;
# Remove old jpg from PhotoTranscoder Cache
12|remo*)
# Check if PMS running
if IsRunning; then
WriteLog "Remove - FAIL - PMS runnning"
Output "Unable to clean caches. PMS is running."
continue
fi
WriteLog "Remove - START"
DoRemovePhotoTranscoder
WriteLog "Remove - PASS"
;;
# Undo
12|undo*)
13|undo*)
DoUndo
;;