bernd-wechner / Degoo

CLI tool(s) for working with Degoo cloud storage
Other
143 stars 41 forks source link

degoo_put: [Errno 22] Invalid argument #7

Closed MDKPredator closed 3 years ago

MDKPredator commented 3 years ago

This error occurs when trying to upload a file with a time zone other than UTC (in my case +1). The problem is in the has_changed method, specifically when trying to calculate LastUploadTime:

LastUploadTime = datetime.datetime.utcfromtimestamp(0).replace(tzinfo=tz.UTC).astimezone(tz.tzlocal()) # Internally it tries to subtract 0 - 3600, which causes the exception

I think this can be fixed by changing the following, working on Windows as on Ubuntu: LastUploadTime = datetime.datetime.now(tz.tzlocal())

growtopiajaw commented 3 years ago

BF871900-38DB-46C9-BF6C-339C51038CC0

Might this somehow be a related issue?

MDKPredator commented 3 years ago

I don't think so, it seems that the modification date does not always exist. I have not managed to replicate the error, but it could be easily fixed by modifying in the "_human_readable_times" method:

m_secs = int(modification)/1000

By

m_secs = 0 if modification is None else int(modification)/1000

bernd-wechner commented 3 years ago

More canonically:

m_secs = int(modification)/1000 if modification else 0

A sensible failsafe indeed.

bernd-wechner commented 3 years ago

The original issue of LastUploadTime may need some thought. There is in fact only one goal there and criterion for testing, namely that when we upload a file, then ask Degoo for the file properties (including the upload time) that this time can be compared meaningfully to the local filesystem's reported modifcation time for the file.

So in testing it, timezones are only relevant if one or the other is not UTC. Which I suspect is the case, namely that the local file modification time is in local time, but the reported upload time by Degoo is in UTC. So to make them comparable, a timezone conversion is needed.

bernd-wechner commented 3 years ago

Fixed in: https://github.com/bernd-wechner/Degoo/commit/92ae25735201d546db460d684a7b1172df97f773