{"record":{"id":"061a798db47a28ee","repo":"subhra74/xdm","slug":"diskerror-errorcode","errorCode":"DiskError","errorMessage":"ErrorCode.DiskError","messagePattern":"ErrorCode\\.DiskError","errorType":"error_code","errorClass":"AssembleFailedException","httpStatus":null,"severity":"critical","filePath":"app/XDM/XDM.Core/Downloader/Progressive/SingleHttp/SingleSourceHTTPDownloader.cs","lineNumber":399,"sourceCode":"                            else\r\n                            {\r\n                                while (len > 0)\r\n                                {\r\n                                    if (this.cancelFlag.IsCancellationRequested) return;\r\n                                    var x = infs.Read(buf, 0, (int)Math.Min(buf.Length, len));\r\n                                    if (x == 0)\r\n                                    {\r\n                                        Log.Debug(\"EOF :: File corrupted\");\r\n                                        throw new Exception(\"EOF :: File corrupted\");\r\n                                    }\r\n                                    try\r\n                                    {\r\n                                        outfs.Write(buf, 0, x);\r\n                                    }\r\n                                    catch (IOException ioe)\r\n                                    {\r\n                                        Log.Debug(ioe, \"AssemblePieces\");\r\n                                        throw new AssembleFailedException(ErrorCode.DiskError, ioe);\r\n                                    }\r\n                                    len -= x;\r\n                                    totalBytes += x;\r\n                                    var prg = (int)(totalBytes * 100 / FileSize);\r\n                                    if (state!.ConvertToMp3) prg /= 2;\r\n                                    this.OnAssembleProgressChanged(prg);\r\n                                }\r\n                            }\r\n                        }\r\n\r\n                        if (this.cancelFlag.IsCancellationRequested) return;\r\n\r\n                        if (state!.ConvertToMp3)\r\n                        {\r\n                            if (mediaProcessor != null)\r\n                            {\r\n                                mediaProcessor.ProgressChanged += (s, e) =>\r\n                                {\r","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/subhra74/xdm/blob/1ca5a25aae007826c859c81bea494e7c102e1242/app/XDM/XDM.Core/Downloader/Progressive/SingleHttp/SingleSourceHTTPDownloader.cs#L381-L417","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nAssemble(pieces, \"/media/usb/movie.mp4\"); // 3GB free, need 8GB -> DiskError\n// after\nif (GetFreeSpace(\"/media/usb\") < FileSize) {\n    Assemble(pieces, \"/home/user/Downloads/movie.mp4\"); // assemble where space exists\n}","handlingStrategy":"validation","validationCode":"var drive = new DriveInfo(Path.GetPathRoot(outFile));\nif (drive.AvailableFreeSpace < FileSize) // pieces + assembled copy need room\n    throw new IOException(\"Not enough free space to assemble\");\nif (File.Exists(outFile) && IsFileLocked(outFile)) throw new IOException(\"Output file is locked\");","typeGuard":null,"tryCatchPattern":"try { downloader.Resume(); }\ncatch (AssembleFailedException e) when (e.ErrorCode == ErrorCode.DiskError) {\n    FreeSpaceOrChangeDestination();\n    RetryAssembly();\n}","preventionTips":["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"],"tags":["disk","assembly","io"],"backgroundTag":"file-write-failed","analyzedSha":"1ca5a25aae007826c859c81bea494e7c102e1242","analyzedAt":"2026-09-13T20:37:40.968Z","contentChangedAt":"2026-09-13T20:37:40.968Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}