From 920611fcb0636ff4d7ab54a5e0ba5e0dab37cb84 Mon Sep 17 00:00:00 2001 From: Aaron Dean <8dino2@gmail.com> Date: Tue, 17 Oct 2023 14:39:30 -0400 Subject: [PATCH 1/2] Update mvd_transfer.sh --- plugins/mvd_transfer.sh | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/plugins/mvd_transfer.sh b/plugins/mvd_transfer.sh index e0988d8..7e8f81f 100755 --- a/plugins/mvd_transfer.sh +++ b/plugins/mvd_transfer.sh @@ -26,16 +26,36 @@ _rsakeylocation="$HOME/.ssh/id_rsa" ## AQTion MVD transfer -if [ -f "${_fullfilepath}" ]; then - ( sleep 10 ) && ( s3cmd put "${_fullfilepath}" s3://${_s3bucket}/${_targetdir}/${_servertargetdir}/${_file} ) & -elif [ -z "${_file}" ]; then - echo "$0 Error: $_file not found. Not transferring anything. :(" - exit 1 -else - echo "Something went wrong other than file not found" +max_retries=5 +retries=0 + +while [ $retries -lt $max_retries ]; do + if [ -f "${_fullfilepath}" ]; then + if lsof "${_fullfilepath}" > /dev/null; then + echo "Error: ${_file} is open or being written to by another process. Not transferring." + exit 1 + else + ( sleep 5 ) && ( s3cmd put "${_fullfilepath}" s3://${_s3bucket}/${_targetdir}/${_servertargetdir}/${_file} ) && break + fi + elif [ -z "${_file}" ]; then + echo "$0 Error: ${_file} not found. Not transferring anything. :(" + exit 1 + else + echo "Something went wrong other than file not found" + exit 1 + fi + + retries=$((retries+1)) + echo "Upload failed (retry $retries of $max_retries). Retrying in 2 seconds..." + sleep 2 +done + +if [ $retries -eq $max_retries ]; then + echo "Max retries reached for ${_file}. Upload failed after $max_retries attempts. Exiting." exit 1 fi + ## Old method, keeping around but unused: # if [ -f "${_filepath}/${_file}" ]; then From 0ea5f9196dd97a69acb06bf183e06b1d9557fd79 Mon Sep 17 00:00:00 2001 From: Aaron Dean <8dino2@gmail.com> Date: Tue, 17 Oct 2023 15:16:12 -0400 Subject: [PATCH 2/2] Update mvd.lua --- plugins/mvd.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/mvd.lua b/plugins/mvd.lua index 8bdb6f4..adc10e6 100644 --- a/plugins/mvd.lua +++ b/plugins/mvd.lua @@ -127,7 +127,8 @@ end function mvd_os_exec(script) gi.dprintf('mvd.lua mvd_os_exec(): '..script..'\n') - local returnstuff = os.execute(script) + local cmd = string.format('nohup %s > script.log 2>&1 &', script) + local returnstuff = os.execute(cmd) gi.dprintf('mvd.lua mvd_os_exec(): returns: '..returnstuff..'\n') return returnstuff end