Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plugins/mvd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 27 additions & 7 deletions plugins/mvd_transfer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down