From bb216a0c047931f05f0ce8a9889b015b7b9129e7 Mon Sep 17 00:00:00 2001 From: bender Date: Sun, 5 Nov 2023 15:57:04 -0500 Subject: [PATCH] Fixed Issue #1 --- __pycache__/config.cpython-310.pyc | Bin 406 -> 591 bytes overdrivedelete.sh | 49 +++++++++++++++++++---------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/__pycache__/config.cpython-310.pyc b/__pycache__/config.cpython-310.pyc index 618727bec509e68ac9155ddb54551ce31e2cdff4..b0f138aabb73ecd225f4e6feb0b1181c94592666 100644 GIT binary patch delta 276 zcmXw!ze>bF5XN_ty{M5`SZF0oEBXjF;(^%M*liPHc5)eS%`W@r@Y47UAs}`>ijQD_ zkKq%z3J!cfX5gETnYa8)RHmv*mg?pE7MD|X_6liGOtJ%}xa5hM%o1~%CkiRl;(?tP z<9oTpjs^rp4%=WHp)c=1(;A^~HZ-i@IqE=GBXmY9bRN8c#zQc$As-t}BLX&U4?dtx zOV;8*H^ZuYi~+VLLTjQ{$>K?Gp;1rK2M9fa#}MsrPDg)62i9SS4u>`!F<#Es{B-&} nn${oXVz*b<%CvPoAM%Srr01NNulW7RacTw23c<7NU;F$AP!dkK delta 88 zcmX@lGL4xxpO=@50SK0}UQRZe$SW%&0_3DHL@}f=Mlq%^MKPr?M=__c1T$!|R_RP` nU{swf$T**oW%4dYZ8m10(jw-`uNnP#IDkwRRu*O!W)5Zm7QGM~ diff --git a/overdrivedelete.sh b/overdrivedelete.sh index 52d1832..9de22c5 100644 --- a/overdrivedelete.sh +++ b/overdrivedelete.sh @@ -5,14 +5,13 @@ #It extracts the contents of the odm into a temp directory so as to point the metadata #file to the export path of the contents of the odm and then deletes the leftover files - source config.env folder=$queue annex=$annex for file in $folder/*.odm do - #Make temp dir in loop so that it clears even if theres any errors + # Make temp dir in loop so that it clears even if there's any errors temp_dir=$(mktemp -d) cd "$temp_dir" @@ -20,28 +19,46 @@ do echo "temp_dir path: $temp_dir" while true; do - if ~/.local/bin/overdrive download $file; then - break + # Run the overdrive download command and capture both stdout and stderr + output=$(~/.local/bin/overdrive download "$file" 2>&1) + exit_status=$? + + # Check if the output contains the specific LicenseError message + if echo "$output" | grep -q "1003"; then + echo "License error detected for file: $file" + echo "$output" # Optionally log this output to a file + break # Break out of the while loop and skip this file + elif [ $exit_status -eq 0 ]; then + echo "Download successful for $file" + break # Successful download, break out of the while loop + else + echo "An unspecified error occurred, retrying in 2 seconds..." + sleep 2 fi - sleep 2 # wait for 2 seconds before retrying done - #Get the name of the downloaded folder + # Get the name of the downloaded folder downloaded_folder=$(find "$temp_dir" -type d -mindepth 1 -maxdepth 1 | head -n 1) - echo "downloaded_folder: $downloaded_folder" + if [ -n "$downloaded_folder" ]; then + echo "downloaded_folder: $downloaded_folder" - #Move the downloaded folder to the destination - mv "$downloaded_folder" "$annex" + # Move the downloaded folder to the destination + mv "$downloaded_folder" "$annex" - #Move the .odm.metadata to the downloaded folder - metadata_file=$(find "$folder" -name "*.odm.metadata") - mv "$metadata_file" "$annex/$(basename "$downloaded_folder")" + # Move the .odm.metadata to the downloaded folder + metadata_file=$(find "$folder" -name "*.odm.metadata") + if [ -n "$metadata_file" ]; then + mv "$metadata_file" "$annex/$(basename "$downloaded_folder")" + fi + else + echo "No downloaded folder found for $file, potentially due to earlier license error." + fi - #Remove temp directory + # Clean up the temporary directory rm -rf "$temp_dir" done -#Remove .odm & .odm.license files -rm $queue/*.odm -rm $queue/*.odm.license \ No newline at end of file +# Remove .odm & .odm.license files +rm -f $folder/*.odm +rm -f $folder/*.odm.license