Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed rclone cmd bug #114

Merged
merged 4 commits into from
Sep 18, 2024
Merged
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
14 changes: 2 additions & 12 deletions script/download-file/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,9 @@ def preprocess(i):
# have to modify the variable from url to temp_url if it is going to be used anywhere after this point
url = url.replace("%", "%%")
temp_download_file = env['CM_DOWNLOAD_FILENAME'].replace("%", "%%")
env['CM_DOWNLOAD_CMD'] = f"rclone {rclone_copy_using} {q}{url}{q} {q}{os.path.join(os.getcwd(), temp_download_file)}{q} -P"
env['CM_DOWNLOAD_CMD'] = f"rclone {rclone_copy_using} {q}{url}{q} {q}{os.path.join(os.getcwd(), temp_download_file)}{q} -P --error-on-no-transfer"
else:
env['CM_DOWNLOAD_CMD'] = f"rclone {rclone_copy_using} {q}{url}{q} {q}{os.path.join(os.getcwd(), env['CM_DOWNLOAD_FILENAME'])}{q} -P"
for i in range(1,5):
url = env.get('CM_DOWNLOAD_URL'+str(i),'')
if url == '':
break
if env["CM_HOST_OS_TYPE"] == "windows":
url = url.replace("%", "%%")
temp_download_file = env['CM_DOWNLOAD_FILENAME'].replace("%", "%%")
env['CM_DOWNLOAD_CMD'] = f" || ((rm -f {env['CM_DOWNLOAD_FILENAME']} || true) && rclone {rclone_copy_using} {q}{url}{q} {q}{os.path.join(os.getcwd(), temp_download_file)}{q} -P)"
else:
env['CM_DOWNLOAD_CMD'] = f" || ((rm -f {env['CM_DOWNLOAD_FILENAME']} || true) && rclone {rclone_copy_using} {q}{url}{q} {q}{os.path.join(os.getcwd(), env['CM_DOWNLOAD_FILENAME'])}{q} -P"
env['CM_DOWNLOAD_CMD'] = f"rclone {rclone_copy_using} {q}{url}{q} {q}{os.path.join(os.getcwd(), env['CM_DOWNLOAD_FILENAME'])}{q} -P --error-on-no-transfer"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What i understood is, if the URL given for rclone is wrong, rclone reads it as an empty directory, that's why we did not get any error code or the exit code value as 1. In order to prevent this happening, --error-on-no-transfer flag is added.


filename = env['CM_DOWNLOAD_FILENAME']
env['CM_DOWNLOAD_DOWNLOADED_FILENAME'] = filename
Expand Down
6 changes: 4 additions & 2 deletions script/download-file/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ fi

if [[ ${require_download} == "1" ]]; then
echo ""
echo ${CM_PRE_DOWNLOAD_CLEAN_CMD}
${CM_PRE_DOWNLOAD_CLEAN_CMD}
if [ -e "${CM_PRE_DOWNLOAD_CLEAN}" ]; then
echo ${CM_PRE_DOWNLOAD_CLEAN_CMD}
${CM_PRE_DOWNLOAD_CLEAN_CMD}
fi

echo ""
echo "${CM_DOWNLOAD_CMD}"
Expand Down
Loading