Skip to content

Commit

Permalink
[fsevents] moved doc strings for polling emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Schott committed Feb 11, 2021
1 parent 10ce63f commit 22ecdd2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 46 deletions.
44 changes: 0 additions & 44 deletions src/maestral/fsevents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,6 @@
emitter which uses period directory snapshots and compares them with a
:class:`watchdog.utils.dirsnapshot.DirectorySnapshotDiff` to generate file system
events.
Looking at the source code for :class:`watchdog.utils.dirsnapshot.DirectorySnapshotDiff`,
the event types are categorised as follows:
* Created event: The inode is unique to the new snapshot. The path may be unique to the
new snapshot or exist in both. In the second case, there will be a preceding Deleted
event or a Moved event with the path as starting point (the old item was deleted or
moved away).
* Deleted event: The inode is unique to the old snapshot. The path may be unique to the
old snapshot or exist in both. In the second case, there will be a subsequent Created
event or a Moved event with the path as end point (something else was created at or
moved to the location).
* Moved event: The inode exists in both snapshots but with different paths.
* Modified event: The inode exists in both snapshots and the mtime or file size are
different. DirectorySnapshotDiff will always use the inode’s path from the old
snapshot.
From the above classification, there can be at most two created/deleted/moved events
that share the same path in one snapshot diff:
* Deleted(path1) + Created(path1)
* Moved(path1, path2) + Created(path1)
* Deleted(path1) + Moved(path0, path1)
Any Modified event will come before a Moved event or stand alone. Modified events will
never be combined by themselves with created or deleted events because they require the
inode to be present in both snapshots.
From the above, we can achieve correct ordering for unique path by always adding Deleted
events to the queue first, Modified events second, Moved events third and Created events
last:
Deleted -> Modified -> Moved -> Created
The ordering won’t be correct between unrelated paths and between files and folder. The
first does not matter for syncing. We solve the second by assuming that when a directory
is deleted, so are its children. And before a child is created, its parent directory
must exist.
MovedEvents which are not unique (their paths appear in other events) will be split
into Deleted and Created events by Maestral.
"""

from watchdog.utils import platform # type: ignore
Expand Down
48 changes: 46 additions & 2 deletions src/maestral/fsevents/polling.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
"""
Looking at the source code for :class:`watchdog.utils.dirsnapshot.DirectorySnapshotDiff`,
the event types are categorised as follows:
* Created event: The inode is unique to the new snapshot. The path may be unique to the
new snapshot or exist in both. In the second case, there will be a preceding Deleted
event or a Moved event with the path as starting point (the old item was deleted or
moved away).
* Deleted event: The inode is unique to the old snapshot. The path may be unique to the
old snapshot or exist in both. In the second case, there will be a subsequent Created
event or a Moved event with the path as end point (something else was created at or
moved to the location).
* Moved event: The inode exists in both snapshots but with different paths.
* Modified event: The inode exists in both snapshots and the mtime or file size are
different. DirectorySnapshotDiff will always use the inode’s path from the old
snapshot.
From the above classification, there can be at most two created/deleted/moved events
that share the same path in one snapshot diff:
* Deleted(path1) + Created(path1)
* Moved(path1, path2) + Created(path1)
* Deleted(path1) + Moved(path0, path1)
Any Modified event will come before a Moved event or stand alone. Modified events will
never be combined by themselves with created or deleted events because they require the
inode to be present in both snapshots.
From the above, we can achieve correct ordering for unique path by always adding Deleted
events to the queue first, Modified events second, Moved events third and Created events
last:
Deleted -> Modified -> Moved -> Created
The ordering won’t be correct between unrelated paths and between files and folder. The
first does not matter for syncing. We solve the second by assuming that when a directory
is deleted, so are its children. And before a child is created, its parent directory
must exist.
MovedEvents which are not unique (their paths appear in other events) will be split
into Deleted and Created events by Maestral.
"""

# Copyright 2011 Yesudeep Mangalapilly <yesudeep@gmail.com>
# Copyright 2012 Google, Inc.
#
Expand Down

0 comments on commit 22ecdd2

Please sign in to comment.