{"record":{"id":"42351c39e2e9a861","repo":"memstechtips/Winhance","slug":"insufficient-disk-space-on-drivename-for-operat","errorCode":null,"errorMessage":"Insufficient disk space on {driveName} for {operationName}. Required: {requiredGB:F2} GB, Available: {availableGB:F2} GB","messagePattern":"Insufficient disk space on (.+?) for (.+?)\\. Required: (.+?) GB, Available: (.+?) GB","errorType":"exception","errorClass":"InsufficientDiskSpaceException","httpStatus":null,"severity":"error","filePath":"src/Winhance.Infrastructure/Features/Common/Services/DismProcessRunner.cs","lineNumber":98,"sourceCode":"            var drive = new DriveInfo(_fileSystemService.GetPathRoot(path)!);\r\n            var availableBytes = drive.AvailableFreeSpace;\r\n\r\n            var availableGB = availableBytes / (1024.0 * 1024 * 1024);\r\n            var requiredGB = requiredBytes / (1024.0 * 1024 * 1024);\r\n\r\n            _logService.LogInformation(\r\n                $\"Disk space check for {operationName}: \" +\r\n                $\"Required: {requiredGB:F2} GB, Available: {availableGB:F2} GB on {drive.Name}\"\r\n            );\r\n\r\n            if (availableBytes < requiredBytes)\r\n            {\r\n                _logService.LogError(\r\n                    $\"Insufficient disk space for {operationName}. \" +\r\n                    $\"Required: {requiredGB:F2} GB, Available: {availableGB:F2} GB\"\r\n                );\r\n\r\n                throw new InsufficientDiskSpaceException(\r\n                    drive.Name,\r\n                    requiredGB,\r\n                    availableGB,\r\n                    operationName\r\n                );\r\n            }\r\n\r\n            return true;\r\n        }\r\n        catch (InsufficientDiskSpaceException)\r\n        {\r\n            throw;\r\n        }\r\n        catch (Exception ex)\r\n        {\r\n            _logService.LogWarning($\"Could not check disk space: {ex.Message}\");\r\n            return true;\r\n        }\r","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/memstechtips/Winhance/blob/f23d554eb2d6400b1827bcc46b91294ffa53fbc9/src/Winhance.Infrastructure/Features/Common/Services/DismProcessRunner.cs#L80-L116","documentation":"InsufficientDiskSpaceException (a custom Winhance exception) thrown by DismProcessRunner.CheckDiskSpaceAsync when DriveInfo.AvailableFreeSpace on the target drive's root is less than requiredBytes. The exception carries DriveName, RequiredGB, AvailableGB, and OperationName so callers can show a precise, actionable message.","triggerScenarios":"CheckDiskSpaceAsync(path, requiredBytes, operationName) is called before a heavyweight operation (ISO creation, WIM export, image mount). GetPathRoot(path) resolves the drive; if AvailableFreeSpace < requiredBytes, the exception is thrown. OperationName like \"ISO creation\" is shown in the message.","commonSituations":"The output/temp drive is the system drive and is low on space. The user pointed output at a small USB/secondary partition. A previous large ISO/WIM filled the drive. The required-space estimate (a fixed GB constant) overestimates for the actual operation. Quotas reduce AvailableFreeSpace below total free space.","solutions":["Free space on the named drive or choose an output path on a drive with more room, then retry.","If the required estimate is conservative, lower the requiredBytes passed in for that operation (after confirming the real need).","Check for disk quotas: AvailableFreeSpace reflects the user's quota, not total free — adjust the quota or run as a user without one.","Clean up stale large files (old ISOs, exported WIMs, temp staging dirs) the app may have left behind.","Run the operation on a different physical drive with adequate free space."],"exampleFix":"// before: a single hard requirement\nif (availableBytes < requiredBytes)\n    throw new InsufficientDiskSpaceException(drive.Name, requiredGB, availableGB, operationName);\n\n// after: warn-but-continue when the estimate has a safety margin, throw only on hard shortfall\nvar safetyFactor = 0.8; // caller may pass a 20% padded estimate\nif (availableBytes < requiredBytes * safetyFactor)\n    throw new InsufficientDiskSpaceException(drive.Name, requiredGB, availableGB, operationName);\nif (availableBytes < requiredBytes)\n    _logService.LogWarning($\"Disk space below estimate for {operationName} but above safety floor; proceeding.\");","handlingStrategy":"validation","validationCode":"// Pre-check free space yourself with the same logic before the heavyweight op.\nlong AvailableBytes(string path)\n{\n    var root = System.IO.Path.GetPathRoot(path);\n    return new System.IO.DriveInfo(root).AvailableFreeSpace;\n}","typeGuard":null,"tryCatchPattern":"catch (InsufficientDiskSpaceException ex)\n{\n    // ex has DriveName, RequiredGB, AvailableGB, OperationName — show a precise 'free N GB on drive X' prompt.\n}","preventionTips":["Choose output paths on drives with adequate free space.","Clean up stale ISOs/WIMs/temp staging dirs left by prior runs.","Account for disk quotas (AvailableFreeSpace reflects quota, not total free)."],"tags":["disk-space","filesystem","dism","io","windows","validation"],"backgroundTag":null,"analyzedSha":"f23d554eb2d6400b1827bcc46b91294ffa53fbc9","analyzedAt":"2026-08-13T17:55:20.922Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}