labbots / google-drive-upload

Bash scripts to upload files to google drive
https://labbots.github.io/google-drive-upload/
MIT License
698 stars 145 forks source link

[BUG] Garbled file names #162

Closed kirill-kalinin closed 3 years ago

kirill-kalinin commented 3 years ago

Uploaded files are getting wrong names

Command example: gupload --config test/myconfig.conf --overwrite --quiet -f test/SomefilenameTestUpload_123.45.apk -c 123.45_apk

Uploaded file name: Some ilenameTes Upload_123.45.apk

Akianonymus commented 3 years ago

--overwrite --quiet -f test/SomefilenameTestUpload_123.45.apk -c 123.45_apk

Are you on latest release ? Because it's working fine here

image

kirill-kalinin commented 3 years ago

Yes, it's the latest release, i had no this problem before last update. Terminal shows proper file name, but uploaded file real name is different.

Screenshot 2021-06-10 at 2 06 41 PM
Akianonymus commented 3 years ago

Well, here it's perfectly fine.

image

I will need debug logs to further investigate in the issue.

Run below command to grab the debug logs and remove sensitive information from the log

gupload --config test/myconfig.conf --overwrite --quiet -f test/SomefilenameTestUpload_123.45.apk -c 123.45_apk -D &> log

file=log
values="$(grep -oE "(CLIENT_ID|CLIENT_SECRET|REFRESH_TOKEN|ACCESS_TOKEN|ROOT_FOLDER|WORKSPACE_FOLDER_ID|uploadlink)=.*" "${file}" | sed "s/.*=//g" | sed -e "s/^[\"]\+//g" -e "s/[\"]\+$//g" -e "s/^[\']\+//g" -e "s/[\']\+$//g" &&
    grep -oE "\"id\"\:.*" "${file}" | sed -e "s/.*\"id\"://" -e 's/[",]*$//' -e 's/["]*$//' -e 's/[,]*$//' -e "s/^ //" -e 's/^"//')"

printf "%s\n" "${values}" | while read -r value; do
    sed "s|${value}|null|g" -i "${file}"
done

( This will use -D flag to show debug logs and &> to redirect all of it to file named log, further commands to remove senstive information )

kirill-kalinin commented 3 years ago

Here is it: log.txt

I should say i use Mac OS

Akianonymus commented 3 years ago

@kirill-kalinin Well, last statement made it clear, primitive mac os sed is messing up again.

Run below command and give output.

echo "$(printf '\t')SomefilenameTestUpload_123.45.apk" | sed "s/$(printf '\t')/tt/"

kirill-kalinin commented 3 years ago

Output: ttSomefilenameTestUpload_123.45.apk

Akianonymus commented 3 years ago

@kirill-kalinin So, i have got the fixes, will push asap.

Currently as a workaround, you can either use bash 4.x or update sed with gnu sed.

Akianonymus commented 3 years ago

@kirill-kalinin Execute below commands and try to upload again.

_path="$(which gupload)" &&
    chmod +w "${_path}" &&
        curl -sL https://github.com/Akianonymus/google-drive-upload/raw/wip/sh/release/gupload -o "${_path}" &&
            echo "Success"
Akianonymus commented 3 years ago

Try the latest release, if not fixed, reopen the issue.