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

Added class EmptyDirectorySnapshot to fix issue #612. #613

Merged
merged 7 commits into from
Jan 19, 2020

Conversation

Ajordat
Copy link
Contributor

@Ajordat Ajordat commented Jan 19, 2020

I've added the class EmptyDirectorySnapshot.

This class is used to fake a DirectorySnapshot of an empty directory. The utility of this is to detect the files and folders of an already-with-content directory as just created.

This can be useful if the application needs to process all the files ignoring if they were created before or after the start of the application.

For example, if the folder has the following structure:

├── folder
│   └── file_in_folder.txt
├── file_a.txt
└── file_b.txt

If we run the following lines of code:

current_snapshot = DirectorySnapshot('/')
diff = DirectorySnapshotDiff(EmptyDirectorySnapshot(), current_snapshot)

The resulting diff will comply with the following asserts:

assert diff.files_created = ['/file_a.txt', '/file_b.txt', '/folder/file_in_folder.txt']
assert diff.dirs_created = ['/', '/folder']

@Ajordat Ajordat changed the title Added class DirectorySnapshotEmpty to fix issue #612. Added class EmptyDirectorySnapshot to fix issue #612. Jan 19, 2020
@BoboTiG
Copy link
Collaborator

BoboTiG commented Jan 19, 2020

I like the idea, great work @Ajordat !

Could you add a line in changelog.rst and it will be perfect :)

@BoboTiG
Copy link
Collaborator

BoboTiG commented Jan 19, 2020

And let me know when the PR is good to review ;)

@Ajordat
Copy link
Contributor Author

Ajordat commented Jan 19, 2020

Done! I think I've finished, review it whenever you want :)

@BoboTiG BoboTiG merged commit 5ee9a38 into gorakhargosh:master Jan 19, 2020
@BoboTiG
Copy link
Collaborator

BoboTiG commented Jan 19, 2020

Great PR, thanks a lot! 💪

@scheung38
Copy link

Thanks @BoboTiG and @Ajordat for being so responsive

@Ajordat Ajordat deleted the feature/empty-directory-snapshot branch January 19, 2020 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants