Fixed Issue #1

This commit is contained in:
bender
2023-11-05 15:57:04 -05:00
parent ee0655da5f
commit bb216a0c04
2 changed files with 33 additions and 16 deletions
Binary file not shown.
+25 -8
View File
@@ -5,14 +5,13 @@
#It extracts the contents of the odm into a temp directory so as to point the metadata #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 #file to the export path of the contents of the odm and then deletes the leftover files
source config.env source config.env
folder=$queue folder=$queue
annex=$annex annex=$annex
for file in $folder/*.odm for file in $folder/*.odm
do 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) temp_dir=$(mktemp -d)
cd "$temp_dir" cd "$temp_dir"
@@ -20,14 +19,27 @@ do
echo "temp_dir path: $temp_dir" echo "temp_dir path: $temp_dir"
while true; do while true; do
if ~/.local/bin/overdrive download $file; then # Run the overdrive download command and capture both stdout and stderr
break output=$(~/.local/bin/overdrive download "$file" 2>&1)
exit_status=$?
# Check if the output contains the specific LicenseError message
if echo "$output" | grep -q "<ErrorCode>1003</ErrorCode>"; 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 fi
sleep 2 # wait for 2 seconds before retrying
done 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) downloaded_folder=$(find "$temp_dir" -type d -mindepth 1 -maxdepth 1 | head -n 1)
if [ -n "$downloaded_folder" ]; then
echo "downloaded_folder: $downloaded_folder" echo "downloaded_folder: $downloaded_folder"
# Move the downloaded folder to the destination # Move the downloaded folder to the destination
@@ -35,13 +47,18 @@ do
# Move the .odm.metadata to the downloaded folder # Move the .odm.metadata to the downloaded folder
metadata_file=$(find "$folder" -name "*.odm.metadata") metadata_file=$(find "$folder" -name "*.odm.metadata")
if [ -n "$metadata_file" ]; then
mv "$metadata_file" "$annex/$(basename "$downloaded_folder")" 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" rm -rf "$temp_dir"
done done
# Remove .odm & .odm.license files # Remove .odm & .odm.license files
rm $queue/*.odm rm -f $folder/*.odm
rm $queue/*.odm.license rm -f $folder/*.odm.license