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

GIF and Video files are not deleted once they have been uploaded #25

Closed
nmrshll opened this issue Dec 13, 2018 · 5 comments · Fixed by #109 or #111
Closed

GIF and Video files are not deleted once they have been uploaded #25

nmrshll opened this issue Dec 13, 2018 · 5 comments · Fixed by #109 or #111
Assignees
Labels
bug Something isn't working

Comments

@nmrshll
Copy link
Contributor

nmrshll commented Dec 13, 2018

GIF files are uploaded but never deleted from local disk

@nmrshll nmrshll changed the title Support GIF files Support GIF files check and deletion Dec 13, 2018
@pacoorozco pacoorozco added this to the v0.4.0 milestone Jul 25, 2019
@pacoorozco pacoorozco self-assigned this Jul 25, 2019
@pacoorozco pacoorozco changed the title Support GIF files check and deletion GIF and Video files are not deleted once they have been uploaded Jul 25, 2019
@pacoorozco pacoorozco added the bug Something isn't working label Jul 25, 2019
@pacoorozco
Copy link
Member

@pacoorozco
Copy link
Member

pacoorozco commented Jul 25, 2019

Trying to fix this bug I've realised that it's very difficult and expensive that to files are the same before deleting the local one. The original code was doing different things depending the media type: gif, video and image

  • For image files: First the image is downloaded from Google Photos 🗑️ (this could take a bit, depending the size of the image, a lot of bandwidth is wasted), then average hash of the image is calculated (convert it in greyscale, resize it in 9x8 and calculate the average, a lot of CPU is wasted) and last the local hash and the remote hash, calculated previously, is compared using a hamming function. It's only working for JPEG or PNG formats.
  • For gif files: Again, the image is downloaded from Google Photos 🗑️ (same problem as above) then a hash, a non-cryptological one, is calculated (a lot of CPU is wasted) and compared.
  • For video files: The code is broken. It has been copied from GIF files so it's not working. 🤦‍♂️

One alternative came to my mind to simplify and fix the problem 💡 :

Compare hashes of the downloaded file and the local one. I don't like to download the image 🗑️, it seems a lot of time/bandwidth wasted (let's imagine to do the same for videos).

But unfortunately the hash of the downloaded file is different from the local one 😮, this is due to Google Photos metadata, EXIF stripping, image & video processing... So this alternative is not doable 😞

A less secure, but acceptable IMO way to check the file was properly uploaded could be rely on the Google Photos response. If Google says that the item was properly uploaded, we would remove it from local storage.

And I'm thinking 🤔 if this deleteAfterUpload is an option that people are using a lot. Are you using it? What do you think about my last alternative?

NOTE: I'm going to disable this option because it's not complete and it's broken for several formats, as I mentioned above.

@fdubuisson
Copy link

Just discovered your tool (very useful for my use case) and would need to use this 'deleteAfterUpload' feature.
The option you propose (rely on the api result) looks ok to me. I don't see a reason to not trust the Google APIs :-)

@kissste
Copy link

kissste commented Aug 15, 2019

I want to use it, please rely on google's API response.

@pacoorozco
Copy link
Member

I'm returning from holidays, and this is gonna be my first issue to work on...

@pacoorozco pacoorozco added wip and removed feedback required question Further information is requested labels Aug 19, 2019
@pacoorozco pacoorozco removed this from the v0.4.0 milestone Aug 19, 2019
pacoorozco added a commit that referenced this issue Aug 20, 2019
Fix issue #25 - Enable object deletion after successful upload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants