Skip to content

Scan, DryRun, Stats and Deduplicate hang forever when the tree contains a named pipe (FIFO) #136

Description

@matt-edmondson

What's wrong

FileScanner.ScanForFiles (FileDeduplicator/FileScanner.cs:35-39, 50) uses Directory.EnumerateFiles. On Unix this returns every entry that is not a directory, including FIFOs, sockets and device nodes, and WalkOptions skips only ReparsePoint. FileHasher.ComputeHash (FileDeduplicator/FileHasher.cs:59-63) then calls File.OpenRead on each one. Opening a FIFO for reading blocks until something opens it for writing, so the Parallel.ForEach in HashFiles (line 21) never finishes. No timeout or cancellation applies. Every verb calls HashFiles, so all of them are affected.

Failure scenario

mkdir t; echo a > t/a; mkfifo t/pipe
ktsu.FileDeduplicator Scan -p t

The output stops after Hashed: a -> ... and the process never ends (killed by timeout 15, exit 124). Real trees can contain FIFOs: home directories, /tmp, application runtime directories, and some build outputs.

Suggested fix

Hash only regular files. In ScanForFiles, drop any entry that isn't a regular file before hashing — on Unix, check the file type (e.g. via stat/File.GetUnixFileMode plus type, or new FileInfo(p) with LinkTarget/attributes) and skip FIFOs, sockets and character/block devices; FileAttributes.Device alone does not reliably catch FIFOs on .NET. Add a test that puts a mkfifo inside a TempTree on Unix and asserts the scan completes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions