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

Auto-delete date mismatch #345

Open
mkirkland4874 opened this issue Jun 30, 2021 · 4 comments
Open

Auto-delete date mismatch #345

mkirkland4874 opened this issue Jun 30, 2021 · 4 comments
Labels

Comments

@mkirkland4874
Copy link

Overview

In certain circumstances, there is a mismatch between the date path generated in base.py and the path generated in autodelete.py for the same image. When certain images are deleted on iCloud (i.e., moved to Recently Deleted album), autodelete.py looks at the wrong path when checking if the recently deleted file exists on the local filesystem and as such, the file is not properly deleted from the local filesystem.

Steps to Reproduce

  1. Have a photo with the following creation date uploaded to iCloud: June 23, 2021 5:34:45PM PST
  2. Use icloudpd to download the image to the local filesystem
  3. Delete the file from iCloud
  4. Run icloudpd with the --auto-delete option enabled
  5. Auto-delete will not properly delete the file that was deleted on iCloud

Expected Behavior

The created_date in base.py should match the created_date in autodelete.py for the same image.

Actual Behavior

Line 380 of base.py results in a created_date of 2021-06-23 17:34:45.892000-07:00 and a download path of Photos/2021/06/23/
380: created_date = photo.created.astimezone(get_localzone())

Line 21 of autodelete.py results in a created_date of 2021-06-24 00:34:45.892000+00:00 and a local path of Photos/2021/06/24/
21: created_date = media.created

Accordingly, the file on the local filesystem is actually located at Photos/2021/06/23/ but autodelete.py checks for it in folder Photos/2021/06/24/ and does not find it, so the file is not deleted from the local filesystem even though it was deleted on iCloud.

Context

N/A

@mkirkland4874
Copy link
Author

This may be a potential fix but I won't be writing a unit test to submit a pull request:

https://github.com/mkirkland4874/icloud_photos_downloader/commit/628a7f474d35503239724c3c70dca85053a9b11f

@steffenmartin
Copy link
Contributor

steffenmartin commented Jun 4, 2023

Just came across this as well as I finally understood the intent of the --auto-delete option (since it really wasn't working due to this bug). So the only people in this world this works for 100% of the time are the ones living on the prime meridian.

Is there any chance this would get fixed? It's just a few lines of code per @mkirkland4874.

Willing to help, let me know.

@AndreyNikiforov
Copy link
Collaborator

@steffenmartin if you can add/update tests to match these bug & fix, that would be a great help!

steffenmartin pushed a commit to steffenmartin/icloud_photos_downloader that referenced this issue Jun 5, 2023
steffenmartin added a commit to steffenmartin/icloud_photos_downloader that referenced this issue Jun 7, 2023
steffenmartin pushed a commit to steffenmartin/icloud_photos_downloader that referenced this issue Jun 24, 2023
steffenmartin pushed a commit to steffenmartin/icloud_photos_downloader that referenced this issue Jun 24, 2023
@steffenmartin
Copy link
Contributor

Pull request #645 created.

steffenmartin pushed a commit to steffenmartin/icloud_photos_downloader that referenced this issue Jun 25, 2023
…oud-photos-downloader#345

Due to the usage of local time conversions tests were sensitive to
execution on machines in a different time zones. Now using timestamp
to get beyond this issue.
AndreyNikiforov pushed a commit that referenced this issue Jul 1, 2023
Due to the usage of local time conversions tests were sensitive to
execution on machines in a different time zones. Now using timestamp
to get beyond this issue.

---------

Co-authored-by: Steffen Martin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants