MStadlmeier / drivesync

Google Drive synchronization for Linux
MIT License
197 stars 26 forks source link

Seemingly random "Invalid request" errors #16

Open Fabian42 opened 5 years ago

Fabian42 commented 5 years ago

I've tried multiple times now to use this program, but when I use an already filled, but slightly outdated local Google Drive folder as the path to sync to, it thinks that that is the latest state and starts deleting files remotely. But when I start with an empty folder, then it downloads for a while, last time it was 2-3 hours, then gives the following error message:

/var/lib/gems/2.3.0/gems/google-api-client-0.9.20/lib/google/apis/core/http_command.rb:211:in `check_status': Invalid request (Google::Apis::ClientError)
    from /var/lib/gems/2.3.0/gems/google-api-client-0.9.20/lib/google/apis/core/api_command.rb:102:in `check_status'
    from /var/lib/gems/2.3.0/gems/google-api-client-0.9.20/lib/google/apis/core/download.rb:94:in `execute_once'
    from /var/lib/gems/2.3.0/gems/google-api-client-0.9.20/lib/google/apis/core/http_command.rb:107:in `block (2 levels) in execute'
    from /var/lib/gems/2.3.0/gems/retriable-2.1.0/lib/retriable.rb:54:in `block in retriable'
    from /var/lib/gems/2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `times'
    from /var/lib/gems/2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `retriable'
    from /var/lib/gems/2.3.0/gems/google-api-client-0.9.20/lib/google/apis/core/http_command.rb:104:in `block in execute'
    from /var/lib/gems/2.3.0/gems/retriable-2.1.0/lib/retriable.rb:54:in `block in retriable'
    from /var/lib/gems/2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `times'
    from /var/lib/gems/2.3.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `retriable'
    from /var/lib/gems/2.3.0/gems/google-api-client-0.9.20/lib/google/apis/core/http_command.rb:96:in `execute'
    from /var/lib/gems/2.3.0/gems/google-api-client-0.9.20/lib/google/apis/core/base_service.rb:351:in `execute_or_queue_command'
    from /var/lib/gems/2.3.0/gems/google-api-client-0.9.20/generated/google/apis/drive_v3/service.rb:772:in `get_file'
    from /home/fabian/Desktop/programs/drivesync-master/src/drive_manager.rb:92:in `download'
    from /home/fabian/Desktop/programs/drivesync-master/src/synchronizer.rb:132:in `download_file'
    from /home/fabian/Desktop/programs/drivesync-master/src/synchronizer.rb:251:in `block in sync'
    from /home/fabian/Desktop/programs/drivesync-master/src/synchronizer.rb:248:in `each'
    from /home/fabian/Desktop/programs/drivesync-master/src/synchronizer.rb:248:in `sync'
    from /home/fabian/Desktop/programs/drivesync-master/src/synchronizer.rb:76:in `run'
    from /home/fabian/Desktop/programs/drivesync-master/drivesync.rb:23:in `sync'
    from /home/fabian/Desktop/programs/drivesync-master/drivesync.rb:58:in `<main>'

When I then try to start the program again, it starts deleting files remotely, because it thinks that the local folder is correct.

MStadlmeier commented 5 years ago

The first sync should definitely be into a fresh, empty folder.

As to the invalid requests: The error occurs while downloading a file, which is a very simple API request. The only parameter that is given is the file ID, which is obtained directly from the API, so I don't see how the request could contain an error.

Did you change the default file size limit and is this error reproducible for you? You may want to try using the development branch of this repository, which includes a more recent google api version.

Fabian42 commented 5 years ago

Maybe it's a file that Google Drive thinks is malware? The malware scanner of Google Drive is so paranoid that I have accumulated at least four haress files that it thinks to be malware.

Fabian42 commented 5 years ago

I started with an empty folder now and most files were downloaded, but some also remotely deleted. Why?

MStadlmeier commented 5 years ago

I would expect any malware filter to work on uploading files, not downloading them, but who knows... It would probably be helpful to know which file is causing the invalid request. To check this, you could insert

puts "Trying to download #{file.id} / #{file.path}..."

into line 91 of src/drive_manager.rb (in the download method, before the @service.get_file line).

If files are deleted remotely, there is likely something wrong with your manifest file (due to cancelled syncs, in your case). I would recommend a hard reset, using

ruby drivesync.rb reset

This will delete the manifest, your local drive folder and ask you to re-authorize the next time you use drivesync.

Fabian42 commented 5 years ago

I did the reset and the code change, now it outputs a lot of "Trying to download / path/to/file.txt" and "Downloading file path/to/file.txt ...", but doesn't actually do anything. No file is actually downloaded into the local folder. And it still deletes remote files.

Fabian42 commented 5 years ago

Update: On a new system, I ran Drivesync in a VM. Still Debian, most things the same. The "Invalid request" error happens consistently on this file: https://drive.google.com/open?id=0B1pVA4gNoJi3d2FxNTJmWWR5VFU

(I hope I'm allowed to share it, it probably doesn't run without the rest of the program data anyway.)

The file is created with 0 Bytes, then that error happens and the file is neiter deleted, nor filled. The file is not marked as malware by Google Drive. I had issues with a different program with files that Google Drive thought were malware, but that file isn't it. Drivesync seems to download those "malware" files without problem, which I think might be against TOS (the user has to do something manually to allow downloading files like that), but I won't complain. Drivesync has also downloaded some other .exe files just fine. But it failed on this one twice now.