Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c87304135b |
No files matched your search
@@ -841,15 +841,15 @@ Only one `scan` runs against a database at a time.
|
|||||||
- For its whole run, `scan` holds a lock on a lock file beside the database. The
|
- For its whole run, `scan` holds a lock on a lock file beside the database. The
|
||||||
lock is taken with the `flock(2)` system call, and only one process can hold
|
lock is taken with the `flock(2)` system call, and only one process can hold
|
||||||
it. The lock file's name is the database's path, with symlinks resolved, plus
|
it. The lock file's name is the database's path, with symlinks resolved, plus
|
||||||
`.lock`. By default that is `/var/lib/sfdupes/db.sqlite.lock`. A path through
|
`.lock`. By default that is `/var/lib/sfdupes/db.sqlite.lock`. Every path to
|
||||||
a symlink names the same lock file.
|
one database therefore names the same lock file.
|
||||||
- `scan` takes the lock before it walks the filesystem or opens the database.
|
- `scan` takes the lock before it walks the filesystem or opens the database.
|
||||||
Just before that, it creates the database file, empty, if it is missing. So
|
Just before that, it creates the database file, empty, if it is missing. So
|
||||||
the lock file is named the same way before the first scan as after. A symlink
|
the lock file is named the same way before the first scan as after. A symlink
|
||||||
at the database path is followed, and its target is created.
|
at the database path is followed, and its target is created.
|
||||||
- A second `scan` against the same database does not wait. It fails at once with
|
- A second `scan` against the same database does not wait. It fails at once with
|
||||||
an error naming the lock file, and exits 1. It has walked nothing and has not
|
an error naming the lock file, and exits 1. It has walked nothing and opened
|
||||||
opened the database. The running scan carries on.
|
nothing. The running scan carries on.
|
||||||
- The lock file is created on first use and never deleted. Only its owner may
|
- The lock file is created on first use and never deleted. Only its owner may
|
||||||
open it. A leftover file blocks nothing. The lock ends with the process that
|
open it. A leftover file blocks nothing. The lock ends with the process that
|
||||||
holds it, however that process ends. Deleting the file while a scan runs would
|
holds it, however that process ends. Deleting the file while a scan runs would
|
||||||
|
|||||||
+1
-1
@@ -1340,7 +1340,7 @@ func assertSecondScanFails(t *testing.T, path string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRunSecondScanThroughSymlinkFails(t *testing.T) {
|
func TestRunSecondScanThroughSymlinkFails(t *testing.T) {
|
||||||
// README §Database: a path through a symlink names the same lock
|
// README §Database: every path to one database names the same lock
|
||||||
// file, so while a scan holds it through one path, a scan through
|
// file, so while a scan holds it through one path, a scan through
|
||||||
// another fails, naming the lock file beside the database's real
|
// another fails, naming the lock file beside the database's real
|
||||||
// path.
|
// path.
|
||||||
|
|||||||
Reference in new issue
Block a user