Skip to content

Library watcher reopens a library closed right after creation #3158

Open

Description

@bernardopg

Issue description

Follow-up to #3145. LibraryManager's directory watcher debounces a new .sdlibrary folder for 500 ms and skips it only while the path is in creating. CreationGuard::drop removes the path as soon as creation finishes, while the folder's own create event is still pending. If the creator calls close_library inside the debounce window, the watcher opens the library again; the reopened copy holds .sdlibrary.lock and the next open fails with AlreadyInUse.

Since migrations run in one transaction (#3147), creation is fast enough to hit this window in normal runs. #3145 fixed the shutdown variant; this is the explicit-close variant.

Steps to reproduce

  1. Create a library through LibraryManager.
  2. Close it immediately.
  3. Wait past the 500 ms debounce.
  4. The library is open again, and reopening it fails with AlreadyInUse.

Platform and versions

  • OS: Arch Linux (kernel 7.2)
  • Spacedrive: main at 4d41a379f, built from source
Development tool versions
bun 1.4.3
cargo 1.97.1 (c980f4866 2026-06-30)
rustc 1.97.1 (8bab26f4f 2026-07-14)

Check for other issues

  • I've checked for other issues, and none exist.

Code of Conduct

  • I agree to follow the Code of Conduct.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions