check / check (push) Waiting to run
Every backup queued every directory and symlink for the second phase. The line ending the walk counted directories, and their stat sizes, as files to back up while its enumerated count left them out, and a symlink was counted as backed up on every run, its target length as data. The walk now sets directories aside: they are recorded before the files are backed up and are never counted as files or data, and the walk's progress estimate leaves out the directories the local index knows. A symlink is checked against its record as a regular file is, its target included, so an unchanged one counts as unchanged. Judgement call: every directory is still written to the local index on every backup, as before; no report shows it. Model: opus-5-5
29 lines
802 B
Go
29 lines
802 B
Go
//nolint:testpackage // exercises the unexported countNonDirectories helper
|
|
package snapshot
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"sneak.berlin/go/vaultik/internal/database"
|
|
)
|
|
|
|
// The walk counts regular files and symlinks, not directories, so the
|
|
// estimate of its count made from the local index's records leaves the
|
|
// directories out. See https://git.eeqj.de/sneak/vaultik/issues/305.
|
|
func TestCountNonDirectories(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
known := map[string]*database.File{
|
|
"/src": {Mode: uint32(os.ModeDir | 0o755)},
|
|
"/src/sub": {Mode: uint32(os.ModeDir | 0o755)},
|
|
"/src/a.txt": {Mode: 0o644},
|
|
"/src/link": {Mode: uint32(os.ModeSymlink | 0o777), LinkTarget: "a.txt"},
|
|
}
|
|
|
|
got := countNonDirectories(known)
|
|
if got != 2 {
|
|
t.Errorf("countNonDirectories = %d, want 2", got)
|
|
}
|
|
}
|