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

Fix a TypeError when deleting the watched folder on Windows #601

Merged
merged 1 commit into from
Dec 11, 2019

Conversation

BoboTiG
Copy link
Collaborator

@BoboTiG BoboTiG commented Dec 10, 2019

On Windows, if one deleted the watched folder (or had no enough rights to use it), that error poped out:

Exception in thread Thread-1:
Traceback (most recent call last):
File "watchdog\observers\winapi.py", line 333, in read_directory_changes
    ctypes.byref(nbytes), None, None)
File "watchdog\observers\winapi.py", line 105, in _errcheck_bool
    raise ctypes.WinError()
PermissionError: [WinError 5] Access refused.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Python37-32\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
File "watchdog\observers\api.py", line 145, in run
    self.queue_events(self.timeout)
File "watchdog\observers\read_directory_changes.py", line 76, in queue_events
    winapi_events = self._read_events()
File "watchdog\observers\read_directory_changes.py", line 73, in _read_events
    return read_events(self._handle, self.watch.path, self.watch.is_recursive)
File "watchdog\observers\winapi.py", line 387, in read_events
    buf, nbytes = read_directory_changes(handle, path, recursive)
File "watchdog\observers\winapi.py", line 340, in read_directory_changes
    return _generate_observed_path_deleted_event()
File "watchdog\observers\winapi.py", line 298, in _generate_observed_path_deleted_event
    event = FILE_NOTIFY_INFORMATION(0, FILE_ACTION_DELETED_SELF, len(path), path.value)
TypeError: expected bytes, str found

I added a non-regression test and used a non-ASCII path to ensure there is no unicode issue as well.

@BoboTiG BoboTiG merged commit 56b712b into gorakhargosh:master Dec 11, 2019
@BoboTiG BoboTiG deleted the fix-windows-deleted-self branch December 11, 2019 16:37
BoboTiG pushed a commit to nuxeo/nuxeo-drive that referenced this pull request Dec 31, 2019
…local sync folder

Fixed by upgrading Watchdog as the fix was sent
upstream with gorakhargosh/watchdog#601.
BoboTiG pushed a commit to nuxeo/nuxeo-drive that referenced this pull request Dec 31, 2019
…local sync folder

Fixed by upgrading Watchdog as the fix was sent
upstream with gorakhargosh/watchdog#601.
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

1 participant