Skip to content

fix(nzbdav): lowercase blob ID when constructing blob path#527

Merged
javi11 merged 2 commits intomainfrom
claude/loving-rhodes-13a175
Apr 22, 2026
Merged

fix(nzbdav): lowercase blob ID when constructing blob path#527
javi11 merged 2 commits intomainfrom
claude/loving-rhodes-13a175

Conversation

@javi11
Copy link
Copy Markdown
Owner

@javi11 javi11 commented Apr 22, 2026

Summary

Fixes Failed to open blob file: no such file or directory errors during NZBDav import scans, where the scan reports total_files: 0 even though the blobs directory is accessible.

Root cause

nzbdav's C# BlobStore writes blob files using Guid.ToString("N") and Guid.ToString(), both of which always emit lowercase hex:

var guidStr = id.ToString("N");     // "0aa2bd24b90c4e06a301dd0d296ad86c"
var firstTwo = guidStr[..2];        // "0a"
var nextTwo  = guidStr.Substring(2, 2); // "a2"
var fileName = id.ToString();       // "0aa2bd24-b90c-4e06-a301-dd0d296ad86c"
// Path: blobs/0a/a2/0aa2bd24-b90c-4e06-a301-dd0d296ad86c

But EF Core stores the NzbBlobId column as uppercase hyphenated text (e.g. 0AA2BD24-B90C-4E06-A301-DD0D296AD86C). altmount was passing that DB value directly into filepath.Join, so on case-sensitive filesystems (Linux ext4, etc.) every os.Open failed, and since count++ only runs on success, the final log showed total_files: 0.

Change

Normalize the blob ID to lowercase before constructing the filesystem path in internal/nzbdav/parser.go. Also add TestParser_Parse_Blobs_UppercaseUUID as a regression test that stores an uppercase UUID in the DB and the lowercase file on disk — the existing tests used 16-char lowercase hex fixtures so they never tripped this bug.

Test plan

  • go test -race ./internal/nzbdav/... — new test passes, existing tests stay green
  • Re-run an NZBDav import scan against a real /blobs directory and confirm no Failed to open blob file errors and a non-zero total_files

nzbdav's C# BlobStore writes blob files using Guid.ToString("N") and
Guid.ToString(), which always emit lowercase hex. The SQLite DB stores
NzbBlobId uppercase (EF Core default TEXT Guid format), so on
case-sensitive filesystems every os.Open failed with "no such file or
directory" and the scan reported total_files: 0.

Normalize the blob ID to lowercase before building the path, and add a
regression test using a real uppercase-hyphenated UUID in the DB and a
lowercase path on disk.

Fixes the "Failed to open blob file" errors during NZBDav import scans.
@javi11 javi11 force-pushed the claude/loving-rhodes-13a175 branch from 6736ad9 to 8640258 Compare April 22, 2026 19:41
…on steps

Add `skip_post_import_links` flag on import queue items so nzbdav migration
imports don't create per-item symlinks or STRM files — library symlinks are
rewritten separately in Phase 2. Surface the 4-step migration workflow
(import, backup, verify mount, run migration) at the top of the NZBDav
import UI.
@javi11 javi11 merged commit 8d54481 into main Apr 22, 2026
2 checks passed
@javi11 javi11 deleted the claude/loving-rhodes-13a175 branch April 22, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant