From 0a4db58fb47bbfb62de2722233f377abb87391ef Mon Sep 17 00:00:00 2001 From: sneak Date: Wed, 11 Nov 2026 03:54:15 +0000 Subject: [PATCH] README: guard the daily cron scan against an unmounted disk (closes #175) 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, and its cron line runs scan only when mountpoint reports /srv as mounted. Model: opus-5-5 --- README.md | 13 +++++++++---- TODO.md | 3 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f82360b..05a1efc 100644 --- a/README.md +++ b/README.md @@ -112,15 +112,20 @@ docker run --rm -v /var/lib/sfdupes:/var/lib/sfdupes sfdupes report > dupes.tsv 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 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. For each other +disk mounted below `/srv`, add `&& mountpoint -q` and its mount point after the +first test. 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 database elsewhere, put `SFDUPES_DATABASE=/path/to/db.sqlite` before the - command on the same line. + the database elsewhere, put `SFDUPES_DATABASE=/path/to/db.sqlite` directly + before `/usr/local/bin/sfdupes`. - `scan` writes nothing to stdout. Its stderr, appended here to `/var/log/sfdupes.log`, holds: - one line naming the database; diff --git a/TODO.md b/TODO.md index 94e5c67..948d427 100644 --- a/TODO.md +++ b/TODO.md @@ -29,6 +29,9 @@ Newest first. An entry ends with its date and its issue or branch, where those 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) - The usage line of `scan` no longer ends in `[flags]`. It is the line `README.md` shows under "Subcommands" (2026-11-11, https://git.eeqj.de/sneak/sfdupes/issues/169)