Support iCloud Drive "Trash" operations (enter "Trash", "Restore" files, and "Delete forever" files from Trash.) - picklepete/pyicloud#467 #468
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Breaking change
There is one minor change in this PR that may break existing uses of the
drive
module.Previous versions of the pyicloud drive module return
root.name
as""
.As part of this change, I added support to return a name for special folders (
root
,trash
) This may break existing uses if they expect the oldroot.name == ""
value, as it now isroot.name == "root"
.The test module has already been updated for this change.
Proposed change
This PR implements functions to support handling of Trash operations on iCloud Drive. Specifically:
As part of the above changes, some enhancements were added:
drive.refresh_root()
anddrive.refresh_trash()
: These re-load the cached_root
and new_trash
objects from iCloud. This is helpful if the root or trash directories change (due to new files being deleted/restored/etc.)root
andtrash
when interacting with these special objects.README.rst
with examples.custom_request
developer function to allow devs/users to try crafting custom iCloud Drive requests without needing to rewrite thedrive
module. This makes it easy for advanced users/devs to quickly try out new operations.There were also two bugs I found helpful to fix as part of the work creating this PR: #465 and #466. I submitted these as separate pull requests, as each are helpful but really independent of each other.
Type of change
Example of code:
Examples from
README.rst
:Additional information
Checklist
(Note -
tests/test_account.py:73:
fails for me on pull ofmaster
. After this PR, all other tests & new tests pass, buttests/test_account.py:73:
still fails for me.)If user exposed functionality or configuration variables are added/changed: