Skip to content

fix: wait for Syncthing temp files in subfolders - #857

Open
m47een wants to merge 1 commit into
Unpackerr:mainfrom
m47een:fix/syncthing-wait-subfolders
Open

m47een wants to merge 1 commit into
Unpackerr:mainfrom
m47een:fix/syncthing-wait-subfolders

Conversation

@m47een

@m47een m47een commented Nov 10, 2026

Copy link
Copy Markdown

Problem

With syncthing = true, hasSyncThingFile only lists the top level of the download folder. Season packs that keep each episode in its own folder don't put temp files there, so extraction can start while Syncthing is still copying volumes.

We hit this with a 5-episode RAR pack, where each episode folder held about 85 × 50 MB volumes. Sonarr reported the download as complete while Syncthing was still copying it. Unpackerr started 2 minutes later, having found only one of the five archives, with no "still syncing" line in the log, and failed with:

extraction failed: extracted size exceeds maximum compression ratio

The RAR header reports the full 4.3 GB, but only the volumes copied so far count towards the compressed size. Because it's a limit error, the item is set to NoRetry and stays failed until someone retries it by hand.

I reproduced the error with xtractr v0.8.0 and MaxRatio: 7.5: the first few volumes of the set fail with this error, and the complete set passes the check.

Fix

hasSyncThingFile now uses filepath.WalkDir, so temp files in subfolders hold the extraction back as well. Walk errors are ignored, since Syncthing renames and removes temp files during the walk. The .tmp match is unchanged.

Testing

  • Added TestHasSyncThingFileFindsTempFileInSubfolder, which fails without this change.
  • go test ./pkg/... passes.

Question for you (not in this PR)

Should a ratio failure stay NoRetry when the RAR volume set is incomplete? This PR closes the Syncthing path, but a set that's incomplete for any other reason would still get stuck, even though a later retry would succeed. I left it alone because the no-retry rule looks deliberate for real zip bombs. I'm happy to send a follow-up if you'd like one.

🤖 Generated with Claude Code

hasSyncThingFile only listed the top level of the download folder.
Season packs that keep each episode in its own folder could therefore
start extracting while Syncthing was still copying volumes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant