check / check (push) Successful in 11m31s
A backup of a directory that holds the local index stored a torn copy of it, its -wal and -shm side files and vaultik.pid, all being written while they were read. The scan now treats these files as excluded, whatever the config says. Their paths come from index_path and the lock directory, with symlinks in their directories resolved the way source paths are. pidlock now owns the lock directory and the PID file name, so the CLI and the scanner use the same path. Model: opus-5-5
33 lines
888 B
Go
33 lines
888 B
Go
//nolint:testpackage // exercises the unexported ownFiles helper
|
|
package snapshot
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// The scan walks source paths with symlinks resolved, so vaultik's own
|
|
// files are named the same way, or a symlinked home would back them up.
|
|
func TestOwnFilesResolvesSymlinkedDirectory(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
realDir, err := filepath.EvalSymlinks(t.TempDir())
|
|
require.NoError(t, err)
|
|
|
|
link := filepath.Join(t.TempDir(), "link")
|
|
require.NoError(t, os.Symlink(realDir, link))
|
|
|
|
paths := ownFiles(filepath.Join(link, "index.sqlite"), link)
|
|
|
|
require.Equal(t, []string{
|
|
filepath.Join(realDir, "index.sqlite"),
|
|
filepath.Join(realDir, "index.sqlite-wal"),
|
|
filepath.Join(realDir, "index.sqlite-shm"),
|
|
filepath.Join(realDir, "index.sqlite-journal"),
|
|
filepath.Join(realDir, "vaultik.pid"),
|
|
}, paths)
|
|
}
|