README: guard the daily cron scan against an unmounted disk (closes #175)
check / check (push) Canceled after 0s

A disk that is not mounted leaves its mount point an empty directory.
scan then deletes every record under it, and the next scan reads every
file again. The README now says so. Its cron line runs scan only when
mountpoint finds the disks mounted, and one sentence says which mount
points to test.

The Description drops its sentence on copies deleted after the scan:
"Reading the reports" and "Goals" already say it.

Model: opus-5-5
This commit is contained in:
sneak committed 2026-11-11 05:26:06 +00:00
1 parent f0b679e9fa
commit f90398182f
2 files changed
+14 -7

No files matched your search

+11 -7
View File
@@ -22,9 +22,8 @@ records the files it finds in an SQLite database. SQLite keeps a whole database
in one file. The database is kept between runs. A rescan reads only new and in one file. The database is kept between runs. A rescan reads only new and
changed files. That makes `scan` cheap enough to run every day from `cron`, the changed files. That makes `scan` cheap enough to run every day from `cron`, the
system's job scheduler. `report`, `trees` and `info` work from the database and system's job scheduler. `report`, `trees` and `info` work from the database and
can run at any time. `report` and `trees` leave out a copy that was deleted can run at any time. `dwim` scans `/` and then prints the `trees` report, for a
after the scan. `dwim` scans `/` and then prints the `trees` report, for a first first look at a new machine with one command.
look at a new machine with one command.
## Getting Started ## Getting Started
@@ -115,15 +114,20 @@ docker run --rm -v /srv:/srv:ro -v /var/lib/sfdupes:/var/lib/sfdupes \
Run `scan` as root, so that it can read every file. `scan` warns about a Run `scan` as root, so that it can read every file. `scan` warns about a
directory it cannot read, and about a new or changed file it cannot read. It directory it cannot read, and about a new or changed file it cannot read. It
skips the path and deletes the records at or below it (see "Rules for the skips the path and deletes the records at or below it (see "Rules for the
walk"). As the file `/etc/cron.d/sfdupes`: walk").
An unmounted disk leaves its mount point empty, so `scan` deletes every record
under it, and the next scan reads every file on the disk again. Test the mount
point of each disk at or below `/srv` with its own `mountpoint -q`, joined with
`&&`, and test `/srv` only when it is one. As the file `/etc/cron.d/sfdupes`:
``` ```
30 3 * * * root /usr/local/bin/sfdupes scan /srv 2>>/var/log/sfdupes.log || tail -n 3 /var/log/sfdupes.log 30 3 * * * root if mountpoint -q /srv; then /usr/local/bin/sfdupes scan /srv 2>>/var/log/sfdupes.log || tail -n 3 /var/log/sfdupes.log; else echo "a disk is not mounted; scan of /srv skipped"; fi
``` ```
- The first scan creates `/var/lib/sfdupes/db.sqlite` and its directory. To keep - The first scan creates `/var/lib/sfdupes/db.sqlite` and its directory. To keep
the database elsewhere, put `SFDUPES_DATABASE=/path/to/db.sqlite` before the the database elsewhere, put `SFDUPES_DATABASE=/path/to/db.sqlite` directly
command on the same line. before `/usr/local/bin/sfdupes`.
- `scan` writes nothing to stdout. Its stderr, appended here to - `scan` writes nothing to stdout. Its stderr, appended here to
`/var/log/sfdupes.log`, holds: `/var/log/sfdupes.log`, holds:
- one line naming the database; - one line naming the database;
+3
View File
@@ -29,6 +29,9 @@
Newest first. An entry ends with its date and its issue or branch, where those Newest first. An entry ends with its date and its issue or branch, where those
are known. are known.
- `README.md` says what a disk that is not mounted does to the database. The
daily `cron` line runs `scan` only when `mountpoint` reports `/srv` as mounted
(2026-11-11, https://git.eeqj.de/sneak/sfdupes/issues/175)
- `report` and `trees` leave out a copy that was deleted after the scan. Each - `report` and `trees` leave out a copy that was deleted after the scan. Each
checks only the copy itself with `lstat`: the file, or the directory at the checks only the copy itself with `lstat`: the file, or the directory at the
top of a tree. A group left with one copy is not reported. A missing `scan` top of a tree. A group left with one copy is not reported. A missing `scan`