Every successful file download via HubClient.downloadFile() leaks the CFNetworkDownload_*.tmp file in the system temp directory. These accumulate silently — in my testing, 50 GB of temp files built up over one day of normal usage.
Root cause: In HubClient+Files.swift, after URLSession.download(for:delegate:) returns a tempURL, it's copied into the blob cache via HubCache.storeFile() which uses copyItem, not moveItem. The original tempURL is never deleted. This happens on the success path, not just errors/cancellation.
Two locations:
- ETag-aware cache flow (~line 698)
- Generic non-ETag fallback (~line 787)
Reproduction: # After a few model downloads via HubApi().snapshot(): du -ch $TMPDIR/CFNetworkDownload_*.tmp | tail -1 # 50G total
Fix: Two lines — try? FileManager.default.removeItem(at: tempURL) after storeFile() in both locations.
Note: #21 fixes this by rewriting the download path to use moveItem(at: tempURL, to: blobPath) instead of copy-to-cache. That PR also eliminates the duplicate downloadBase copy by using symlinks, halving disk usage per model. It's been open since December 2025.
Every successful file download via HubClient.downloadFile() leaks the CFNetworkDownload_*.tmp file in the system temp directory. These accumulate silently — in my testing, 50 GB of temp files built up over one day of normal usage.
Root cause: In HubClient+Files.swift, after URLSession.download(for:delegate:) returns a tempURL, it's copied into the blob cache via HubCache.storeFile() which uses copyItem, not moveItem. The original tempURL is never deleted. This happens on the success path, not just errors/cancellation.
Two locations:
Reproduction: # After a few model downloads via HubApi().snapshot(): du -ch $TMPDIR/CFNetworkDownload_*.tmp | tail -1 # 50G total
Fix: Two lines — try? FileManager.default.removeItem(at: tempURL) after storeFile() in both locations.
Note: #21 fixes this by rewriting the download path to use moveItem(at: tempURL, to: blobPath) instead of copy-to-cache. That PR also eliminates the duplicate downloadBase copy by using symlinks, halving disk usage per model. It's been open since December 2025.