mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-22 17:34:54 +01:00
notmuch new: Scan directory whenever fs mtime is not equal to db mtime
Previously, we would only scan a directory if the filesystem modification time was strictly newer than the database modification time for the directory. This would cause a problem for systems with an unstable clock, (if a new mail was added to the filesystem, then the system clock rolled backward, "notmuch new" would not find the message until the clock caught up and the directory was modified again). Now, we always scan the directory if the modification time of the directory is not exactly the same between the filesystem and the database. This avoids the problem described above even with an unstable system clock.
This commit is contained in:
parent
c7b4d15d0a
commit
73198f5c74
1 changed files with 10 additions and 3 deletions
|
@ -308,9 +308,16 @@ add_files_recursive (notmuch_database_t *notmuch,
|
|||
next = NULL;
|
||||
}
|
||||
|
||||
/* If this directory hasn't been modified since the last
|
||||
* "notmuch new", then we can skip the second pass entirely. */
|
||||
if (fs_mtime <= db_mtime)
|
||||
/* If the directory's modification time in the filesystem is the
|
||||
* same as what we recorded in the database the last time we
|
||||
* scanned it, then we can skip the second pass entirely.
|
||||
*
|
||||
* We test for strict equality here to avoid a bug that can happen
|
||||
* if the system clock jumps backward, (preventing new mail from
|
||||
* being discovered until the clock catches up and the directory
|
||||
* is modified again).
|
||||
*/
|
||||
if (fs_mtime == db_mtime)
|
||||
goto DONE;
|
||||
|
||||
/* Pass 2: Scan for new files, removed files, and removed directories. */
|
||||
|
|
Loading…
Reference in a new issue