roleoroleo / yi-hack-MStar.gdrive

Google drive loader for yi smart ip camera (MStar based)
MIT License
25 stars 6 forks source link

Failed to upload to g-drive due to 401 unauthorized #5

Open denven opened 3 years ago

denven commented 3 years ago

It worked fine a few days ago, however, no files are uploaded to g-drive these days when I check google drive.

The bash scripts are running after reboot, I checked the upload script log, found many items as following:

WARNING: Fri Nov 27 02:10:58 PST 2020 : Can not send metadata of the file. Something happen. Trying to send metadata of the file again

And the log comes from code:

if grep -q "401 Unauthorized" ${gdrive_dir}tmp/lastFileMetadataInfo; then echo "WARNING: $(date) : Can not send metadata of the file. Token was expired. Trying to refresh token and send metadata again" renew_token else echo "WARNING: $(date) : Can not send metadata of the file. Something happen. Trying to send metadata of the file again" echo $(cat ${gdrive_dir}tmp/lastFileMetadataInfo) sleep 5 fi

So, why the unauthorized happened? does it need to re-do the whole google API authentication process after a reboot?

roleoroleo commented 3 years ago

I think it's a bug, I have the same problem. I tried to fix it but I failed. Unfortunately I didn't write the code and I don't know it very well. I need help.

denven commented 3 years ago

I think it's a bug, I have the same problem. I tried to fix it but I failed. Unfortunately I didn't write the code and I don't know it very well. I need help.

{ "error": { "errors": [ { "domain": "global", "reason": "notFound", "message": "File not found: 1-oWzNNm0j-TwEL28PAITsFnxD1zwAZM9.", "locationType": "parameter", "location": "fileId" } ], "code": 404, "message": "File not found: 1-oWzNNm0j-TwEL28PAITsFnxD1zwAZM9." } }

denven commented 3 years ago

I think it's a bug, I have the same problem. I tried to fix it but I failed. Unfortunately I didn't write the code and I don't know it very well. I need help.

This shell script is not easy to maintain as it uses several global variables among functions, and many infinite loop. There are several bugs inside, some abnormal operation may trigger new issues.

This issue is caused by user deletion of directories in google drive, the script fails to upload to the deleted directory and runs into a dead loop, so it fails all the time.

Please add me as a committer, I've fixed on my own camera, hope there is no side-effect to other features.

roleoroleo commented 3 years ago

Thank you for your code.

denven commented 3 years ago

Thank you for your code.

Glad to commit