Skip to content
This repository has been archived by the owner on Feb 12, 2021. It is now read-only.

Download with deleteRemoved option should not delete subdirectory #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brzpegasus
Copy link

Fixes #54

To sum it up, when you try to download a remote directory called remote-dir from a bucket, and specify the local directory as local-dir, I would expect just the contents of remote-dir to download, not the directory itself, so remote-dir/ shouldn't need to be pushed to allS3Objects when listing remote objects, but it is right now.

If local-dir has a subdirectory called foo (valid directory that also exists remotely and thus should be retained), it will get deleted on the next download attempt. Because of the extra remote-dir/ entry in allS3Objects, when you start diff'ing the remote objects against the local ones, you end up checking if the string foo/ is contained within the remote-dir/ s3Object.key string, which is an empty string after the prefix truncation. And since it isn't, deleteLocalDir() gets called.

enabled.

* allS3Objects should not contain the directory specified by 'prefix'.

Fixes andrewrk#54
@andrewrk
Copy link
Owner

Thank you for doing this investigation and fix. This is a big deal. I want to take the proper time to fully understand the explanation that you gave here before merging, and I will try to do that before the end of the day.

@andrewrk
Copy link
Owner

I'd like to see if I can add a test case to cover this too, since it's such a tricky case.

@brzpegasus
Copy link
Author

Sounds good!

@faceleg
Copy link
Contributor

faceleg commented Oct 7, 2015

As andrew said, this needs a test.

@OmgImAlexis OmgImAlexis modified the milestone: Backlog Aug 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

deleteRemoved option with downloadDir causes some local directories to disappear entirely
4 participants