-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
mlocate implements incremental updates compared to its predecessor slocate. Overall, mlocate determines whether to further index the contents of a directory based on whether the directory’s mtime (modification time) or ctime (change time) has changed.
1 /* "relative" may now become a symlink to somewhere else. So we use it only
2 in safe_chdir (). */
3 entries_mark = obstack_alloc (&scan_dir_state.data_obstack, 0);
4 dir.path = path;
5 time_get_ctime (&dir.time, &st);
6 time_get_mtime (&mtime, &st);
7 if (time_compare (&dir.time, &mtime) < 0)
8 dir.time = mtime;
9 while (old_dir.path != NULL && (cmp = dir_path_cmp (old_dir.path, path)) < 0)
10 {
11 old_dir_skip ();
12 old_dir_next_header ();
13 }
14 did_chdir = false;
15 have_subdir = false;
16 if (old_dir.path != NULL && cmp == 0
17 && time_compare (&dir.time, &old_dir.time) == 0
18 && (dir.time.sec != 0 || dir.time.nsec != 0))
19 {
20 res = copy_old_dir (&dir);
21 if (res != -1)
22 {
23 have_subdir = res;
24 old_dir_next_header ();
25 goto have_dir;
26 }
27 }
28 if (time_is_current (&dir.time))
29 {
30 /* The directory might be changing right now and we can't be sure the
31 timestamp will be changed again if more changes happen very soon, mark
32 the timestamp as invalid to force rescanning the directory next time
33 updatedb is run. */
34 dir.time.sec = 0;
35 dir.time.nsec = 0;
36 }
37 did_chdir = true;
38 if (safe_chdir (cwd_fd, relative, &st) != 0)
39 goto err_chdir;
40 res = scan_cwd (&dir);
41 if (res == -1)
42 goto err_chdir;
43 have_subdir = res;
44 have_dir:
45 write_directory (&dir);
46 if (have_subdir != false)
47 {
48 if (did_chdir == false)
49 {
50 did_chdir = true;
51 if (safe_chdir (cwd_fd, relative, &st) != 0)
52 goto err_entries;
53 }
54 scan_subdirs (&dir, &st);
55 }
Metadata
Metadata
Assignees
Labels
No labels