subhra74/xdm · critical · AssembleFailedException
DiskError
DiskError
Error message
ErrorCode.DiskError
What it means
During AssemblePieces, writing concatenated bytes to the output file throws an IOException. The downloader wraps it in AssembleFailedException with ErrorCode.DiskError, signaling the final-file write failed (assembly stage, not network).
Solutions
- Free disk space at least the size of the final file (pieces + assembled copy are needed simultaneously).
- Close applications holding the output file open; exclude the folder from antivirus/backup locks.
- Assemble to a different healthy drive, then move the finished file.
- Check the destination disk for filesystem errors.
Example fix
// before
Assemble(pieces, "/media/usb/movie.mp4"); // 3GB free, need 8GB -> DiskError
// after
if (GetFreeSpace("/media/usb") < FileSize) {
Assemble(pieces, "/home/user/Downloads/movie.mp4"); // assemble where space exists
} Defensive patterns
Strategy: validation
Validate before calling
var drive = new DriveInfo(Path.GetPathRoot(outFile));
if (drive.AvailableFreeSpace < FileSize) // pieces + assembled copy need room
throw new IOException("Not enough free space to assemble");
if (File.Exists(outFile) && IsFileLocked(outFile)) throw new IOException("Output file is locked"); Try / catch
try { downloader.Resume(); }
catch (AssembleFailedException e) when (e.ErrorCode == ErrorCode.DiskError) {
FreeSpaceOrChangeDestination();
RetryAssembly();
} Prevention
- Ensure free space >= final file size before assembly
- Close players/AV holding the output file
- Assemble to a local healthy drive then move
- Check quota and disk errors on the destination
When it happens
Trigger: outfs.Write(buf, 0, x) raises IOException while writing the assembled output - disk full on the destination, output file locked, or device error during final merge.
Common situations: Disk space exhausted by both pieces and the assembled copy, output file opened by a media player/antivirus during assembly, removable drive disconnected, quota exceeded.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
AI-assisted analysis of subhra74/xdm@1ca5a25aae (2026-09-13).
Data as JSON: /api/errors/061a798db47a28ee.
Report an issue: GitHub.
Appendix: source
Thrown at app/XDM/XDM.Core/Downloader/Progressive/SingleHttp/SingleSourceHTTPDownloader.cs:399
else
{
while (len > 0)
{
if (this.cancelFlag.IsCancellationRequested) return;
var x = infs.Read(buf, 0, (int)Math.Min(buf.Length, len));
if (x == 0)
{
Log.Debug("EOF :: File corrupted");
throw new Exception("EOF :: File corrupted");
}
try
{
outfs.Write(buf, 0, x);
}
catch (IOException ioe)
{
Log.Debug(ioe, "AssemblePieces");
throw new AssembleFailedException(ErrorCode.DiskError, ioe);
}
len -= x;
totalBytes += x;
var prg = (int)(totalBytes * 100 / FileSize);
if (state!.ConvertToMp3) prg /= 2;
this.OnAssembleProgressChanged(prg);
}
}
}
if (this.cancelFlag.IsCancellationRequested) return;
if (state!.ConvertToMp3)
{
if (mediaProcessor != null)
{
mediaProcessor.ProgressChanged += (s, e) =>
{
View on GitHub (pinned to 1ca5a25aae)