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

Avoid race condition crash when a directory is swapped for a file #513

Merged
merged 1 commit into from
Feb 16, 2019
Merged

Avoid race condition crash when a directory is swapped for a file #513

merged 1 commit into from
Feb 16, 2019

Conversation

pR0Ps
Copy link
Contributor

@pR0Ps pR0Ps commented Jan 23, 2019

This commit builds off the race condition checking introduced in 2e83199, but also correctly handles the case where a directory is replaced with a file before it can be walked.

For example:

  1. [external] create /a/b/c.txt
  2. [watchdog] walk /a (contains directory /a/b/ at this point)
  3. [external] rm -rf /a/b/
  4. [external] touch /a/b
  5. [watchdog] walk /a/b/ (raises NotADirectoryError/ENOTDIR)

Also adds a test case that runs through the above example to ensure that an exception is no longer raised.

This commit builds off the race condition checking introduced in
2e83199, but also correctly handles the case where a directory is
replaced with a file before it can be walked.

For example:
1. [external] create /a/b/c.txt
2. [watchdog] walk /a (contains directory /a/b/ at this point)
3. [external] rm -rf /a/b/
4. [external] touch /a/b
5. [watchdog] walk /a/b/ (raises NotADirectoryError/ENOTDIR)

Also adds a test case that runs through the above example to ensure that
an exception is no longer raised.
Copy link
Collaborator

@BoboTiG BoboTiG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@BoboTiG BoboTiG merged commit 19eb494 into gorakhargosh:master Feb 16, 2019
@BoboTiG
Copy link
Collaborator

BoboTiG commented Feb 16, 2019

Thanks @pR0Ps :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants