{"record":{"id":"444723561e48f698","repo":"LykosAI/StabilityMatrix","slug":"failed-to-organize-files-and-rollback-was-incomplete-string","errorCode":null,"errorMessage":"Failed to organize files and rollback was incomplete: {string.Join(\"; \", rollbackErrors)}","messagePattern":"Failed to organize files and rollback was incomplete: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"critical","filePath":"StabilityMatrix.Avalonia/Services/ModelOrganizationService.cs","lineNumber":157,"sourceCode":"            {\n                var targetDirectory = Path.GetDirectoryName(move.TargetPath);\n                if (!string.IsNullOrWhiteSpace(targetDirectory))\n                {\n                    Directory.CreateDirectory(targetDirectory);\n                }\n\n                await FileTransfers\n                    .MoveFileAsync(new FilePath(move.SourcePath), new FilePath(move.TargetPath))\n                    .ConfigureAwait(false);\n                completedMoves.Add(move);\n            }\n        }\n        catch (Exception ex)\n        {\n            var rollbackErrors = await RollbackMovesAsync(completedMoves).ConfigureAwait(false);\n            if (rollbackErrors.Count > 0)\n            {\n                throw new IOException(\n                    $\"Failed to organize files and rollback was incomplete: {string.Join(\"; \", rollbackErrors)}\",\n                    ex\n                );\n            }\n\n            throw;\n        }\n    }\n\n    private static void EnsureMoveTargetsAvailable(IReadOnlyList<ModelOrganizationFileMove> moves)\n    {\n        foreach (var move in moves.Where(move => !PathsEqual(move.SourcePath, move.TargetPath)))\n        {\n            if (File.Exists(move.TargetPath))\n            {\n                throw new FileTransferExistsException(move.SourcePath, move.TargetPath);\n            }\n        }","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/Services/ModelOrganizationService.cs#L139-L175","documentation":"ApplyFileMovesAsync wraps a failed organize operation: after an exception, it attempts to roll back completed moves; if the rollback itself partially fails, it throws an IOException whose message lists the rollback errors, chaining the original exception. This indicates the models directory may be left in a mixed state.","triggerScenarios":"A disk error, permission denial, path-length limit, or locked file causes a move to fail mid-plan AND the compensating rollback of earlier successful moves also encounters errors (files locked, destination busy, permissions).","commonSituations":"Moving models while a trainer/UI holds files open; antivirus locking files mid-move; cross-volume moves failing on partial completion; permission differences between source and destination directories; disk full during a large move.","solutions":["Close applications locking the model files (UI, trainers, indexers) and retry the organize","Inspect the joined rollback error list in the message and the inner exception to fix the root cause (permissions/disk space)","Manually reconcile the affected files using the reported paths (move remaining files to destinations per the plan)","Retry the operation after freeing disk space or fixing ACLs; take a backup of the models root before large reorganizations"],"exampleFix":"// before\ntry { await service.MoveModelFileAsync(model, root, dest); }\ncatch (IOException ex) { /* message lists rollback errors; inner ex is original cause */ }\n// after\ncatch (IOException ex)\n{\n    logger.LogError(ex, \"Organize failed; inner: {Inner}\", ex.InnerException?.Message);\n    // reconcile files listed in ex.Message, then retry\n}","handlingStrategy":"try-catch","validationCode":"foreach (var move in plan)\n{\n    if (!File.Exists(move.Source)) throw new FileNotFoundException(move.Source);\n    if (move.Destination is { } d && File.Exists(d)) throw new IOException($\"Destination exists: {d}\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    await organizationService.MoveModelFileAsync(model, root, dest);\n}\ncatch (IOException ex) when (ex.Message.Contains(\"rollback was incomplete\"))\n{\n    logger.LogError(ex, \"Organize failed with partial rollback: {Msg}\", ex.Message);\n    // manually reconcile per ex.Message paths, then retry\n}","preventionTips":["Ensure no app holds model files open during reorganization","Check disk space and permissions on source and destination","Back up the models root before large plans","Move within the same volume when possible"],"tags":["file-move","rollback","io","partial-failure"],"backgroundTag":"file-write-failed","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}