Updated 'repair_item'
InternetArchive/repair_item: originally planned in 2020 as a Bash script to find missing files in shows and then add them, it was not turned into the current form until May 2024. Now, with the heavy loading of the IA servers, normal uploads are timing out and being aborted. This script is more "determined" to upload files and usually successfully "repairs" shows that need it.
This commit is contained in:
parent
7a4290fcdd
commit
6805cd662b
@ -23,15 +23,15 @@
|
||||
# BUGS: ---
|
||||
# NOTES: ---
|
||||
# AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com
|
||||
# VERSION: 0.0.7
|
||||
# VERSION: 0.0.9
|
||||
# CREATED: 2020-01-05 22:42:46
|
||||
# REVISION: 2024-05-17 20:49:47
|
||||
# REVISION: 2024-06-14 18:03:58
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
#set -o nounset # Treat unset variables as an error
|
||||
|
||||
VERSION="0.0.7"
|
||||
VERSION="0.0.9"
|
||||
|
||||
SCRIPT=${0##*/}
|
||||
# DIR=${0%/*}
|
||||
@ -90,13 +90,15 @@ trap 'cleanup_temp $TMP1' SIGHUP SIGINT SIGPIPE SIGTERM EXIT
|
||||
|
||||
#=== FUNCTION ================================================================
|
||||
# NAME: Upload
|
||||
# DESCRIPTION: Upload a file to the Internet Archive with various options
|
||||
# DESCRIPTION: Uploads a file to the Internet Archive with various options.
|
||||
# Any output from the 'ia' command invocation is saved in
|
||||
# a temporary file and the name reported to the caller
|
||||
# PARAMETERS: 1 - the item id (e.g. 'hpr1234'
|
||||
# 2 - the path to the file for upload
|
||||
# 3 - (optional) the path to the file on the IA
|
||||
# 4 - (optional) list of options for 'ia upload' enclosed as
|
||||
# a string
|
||||
# RETURNS: Nothing
|
||||
# RETURNS: Exit code of last command
|
||||
#===============================================================================
|
||||
Upload () {
|
||||
local id=${1}
|
||||
@ -104,16 +106,23 @@ Upload () {
|
||||
local remote=${3:-}
|
||||
local options=${4:-}
|
||||
|
||||
local RES
|
||||
|
||||
if [[ -e $file ]]; then
|
||||
if [[ -z $remote ]]; then
|
||||
# shellcheck disable=SC2086
|
||||
ia upload ${id} ${file} ${options}
|
||||
ia upload ${id} ${file} ${options} > /dev/null 2>&1
|
||||
RES=$?
|
||||
return $RES
|
||||
else
|
||||
# shellcheck disable=SC2086
|
||||
ia upload ${id} ${file} --remote-name=${remote} ${options}
|
||||
ia upload ${id} ${file} --remote-name=${remote} ${options} > /dev/null 2>&1
|
||||
RES=$?
|
||||
return $RES
|
||||
fi
|
||||
else
|
||||
echo "File missing: $file"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@ -418,7 +427,7 @@ else
|
||||
# upload when the system is overloaded, but these are non-fatal.
|
||||
#
|
||||
until eval "$cmd"; do
|
||||
coloured 'red' "Failure when invoking the Upload command!"
|
||||
coloured 'red' "Failure when uploading $file"
|
||||
((retries++))
|
||||
|
||||
printf '%s Failed to upload %s to the IA [%d]\n' \
|
||||
@ -435,6 +444,7 @@ else
|
||||
sleep $sleeptime
|
||||
done # until eval ...
|
||||
|
||||
coloured 'green' "Uploaded $file to the IA"
|
||||
echo "$(date +%Y%m%d%H%M%S) Uploaded $file to the IA" >> "$LOGFILE"
|
||||
fi
|
||||
|
||||
@ -462,7 +472,7 @@ fi
|
||||
if [[ $failures -gt 0 ]]; then
|
||||
coloured 'red' \
|
||||
"There $(ngettext "was $failures upload failure" "were $failures upload failures" $failures)"
|
||||
coloured 'yellow' 'Run this script again to repeat the repair attemmpt'
|
||||
coloured 'yellow' 'Run this script again to repeat the repair attempt'
|
||||
fi
|
||||
|
||||
# vim: syntax=sh:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21:fdm=marker
|
||||
|
Loading…
Reference in New Issue
Block a user