Overview
When specifying the delete-after-download flag on CLI the media item is deleted from iCloud whether or not the download succeeds. This is, I'd wager, something that folks will be surprised by (I definitely was).
Steps to Reproduce
- Execute any download command that includes the
delete-after-download flag:
icloudpd --directory . --username <user> --delete-after-download --recent 100 --folder-structure <photo_dir>
- I think the check to reproduce this, you probably need to short circuit the download_media function to skip to
else condition.
- Observe the ouput, the file is not downloaded, but it is deleted from
iCloud:
Error downloading RPReplay_Final1651790030.mp4, retrying after 5 seconds...
Error downloading RPReplay_Final1651790030.mp4, retrying after 10 seconds...
Error downloading RPReplay_Final1651790030.mp4, retrying after 15 seconds...
Error downloading RPReplay_Final1651790030.mp4, retrying after 20 seconds...
Error downloading RPReplay_Final1651790030.mp4, retrying after 25 seconds...
Could not download RPReplay_Final1651790030.mp4! Please try again later.
Downloading/RPReplay_Final1651790030.mp4: 68%|6| 68/102023-04-01 01:00:50 INFO Deleting RPReplay_Final1651790030.mp4
Expected Behavior
It makes sense, that if a download fails, that the file in iCloud should not be deleted. It puts the user in a position where they now have to negotiate restoring a photo/video, instead of just trying to download it again in the normal fashion.
Actual Behavior
The file is not downloaded to disk and is deleted from iCloud. In my case, I'm going to have to now figure out which files I don't have locally and attempt to restore all of them (hundreds, potentially over a thousand files) so that I can download them again.
Context
I started a branch to work on this, but the issue is that the result of the download is nested so far away from the code that governs deleting after download, it would either require passing in the delete-after-download flag to the download function (which might work) and make the adjustment there.
Otherwise, this download function, that appears to just be the result of calling this download_builder factory function needs to actually return the result of the download so that it (probably as a bool) can be evaluated with the delete-after-download flag to make an informed decision about deletion.
Overview
When specifying the
delete-after-downloadflag on CLI the media item is deleted fromiCloudwhether or not the download succeeds. This is, I'd wager, something that folks will be surprised by (I definitely was).Steps to Reproduce
delete-after-downloadflag:elsecondition.iCloud:Expected Behavior
It makes sense, that if a download fails, that the file in
iCloudshould not be deleted. It puts the user in a position where they now have to negotiate restoring a photo/video, instead of just trying to download it again in the normal fashion.Actual Behavior
The file is not downloaded to disk and is deleted from
iCloud. In my case, I'm going to have to now figure out which files I don't have locally and attempt to restore all of them (hundreds, potentially over a thousand files) so that I can download them again.Context
I started a branch to work on this, but the issue is that the result of the download is nested so far away from the code that governs deleting after download, it would either require passing in the
delete-after-downloadflag to thedownloadfunction (which might work) and make the adjustment there.Otherwise, this download function, that appears to just be the result of calling this download_builder factory function needs to actually return the result of the download so that it (probably as a
bool) can be evaluated with thedelete-after-downloadflag to make an informed decision about deletion.