check / check (push) Successful in 10m54s
The default config backs up the home directory, which holds vaultik's local index and PID file, so a backup stored a torn copy of the index it was writing. The scan now skips the index, its SQLite side files and the PID file whatever the config says, including when index_path or its directory is a symlink. database purge removes the same list of index files. Model: opus-5-5
33 lines
915 B
Go
33 lines
915 B
Go
//nolint:testpackage // exercises the unexported indexAndLockFiles 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 TestIndexAndLockFilesResolvesSymlinkedDirectory(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 := indexAndLockFiles(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)
|
|
}
|