1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-15 23:46:11 +00:00

fix(analyze): Fix race condition in currentPath

This commit is contained in:
Jack Phallen
2026-01-11 23:44:55 -05:00
parent 91fcbb925b
commit 47ce1cb75b
4 changed files with 19 additions and 16 deletions

View File

@@ -45,9 +45,10 @@ func TestScanPathConcurrentBasic(t *testing.T) {
}
var filesScanned, dirsScanned, bytesScanned int64
current := ""
current := &atomic.Value{}
current.Store("")
result, err := scanPathConcurrent(root, &filesScanned, &dirsScanned, &bytesScanned, &current)
result, err := scanPathConcurrent(root, &filesScanned, &dirsScanned, &bytesScanned, current)
if err != nil {
t.Fatalf("scanPathConcurrent returned error: %v", err)
}
@@ -361,10 +362,11 @@ func TestScanPathPermissionError(t *testing.T) {
}()
var files, dirs, bytes int64
current := ""
current := &atomic.Value{}
current.Store("")
// Scanning the locked dir itself should fail.
_, err := scanPathConcurrent(lockedDir, &files, &dirs, &bytes, &current)
_, err := scanPathConcurrent(lockedDir, &files, &dirs, &bytes, current)
if err == nil {
t.Fatalf("expected error scanning locked directory, got nil")
}