{"record":{"id":"9fd21d7cf8664653","repo":"d2phap/ImageGlass","slug":"ige-could-not-finalize-destfilepath-moveerr","errorCode":null,"errorMessage":"IGE: could not finalize '{destFilePath}'. {moveError}","messagePattern":"IGE: could not finalize '(.+?)'\\. (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"source/ImageGlass.Lib/Common/Photoing/Codecs/Registry/CodecEncodePipeline.cs","lineNumber":84,"sourceCode":"                ? await EncodeMultiFrameAsync(codec, photo, tempPath, transform, quality, token).ConfigureAwait(false)\n                : await EncodeSingleFrameAsync(codec, photo, tempPath, transform, quality, token).ConfigureAwait(false);\n\n            if (result.Unsupported)\n            {\n                TryDelete(tempPath);\n                return false;\n            }\n            if (!result.Succeeded)\n            {\n                TryDelete(tempPath);\n                throw new InvalidDataException(\n                    $\"IGE: '{codec.CodecName}' could not write the image. {result.Error}\".TrimEnd());\n            }\n\n            if (!TryPromote(tempPath, destFilePath, out var moveError))\n            {\n                TryDelete(tempPath);\n                throw new IOException($\"IGE: could not finalize '{destFilePath}'. {moveError}\".TrimEnd());\n            }\n\n            return true;\n        }\n        catch (OperationCanceledException)\n        {\n            TryDelete(tempPath);\n            throw;\n        }\n        catch\n        {\n            TryDelete(tempPath);\n            throw;\n        }\n    }\n\n\n    /// <summary>","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/d2phap/ImageGlass/blob/4a3c4feceffc5a8bb5e56ba836509634aaae47a9/source/ImageGlass.Lib/Common/Photoing/Codecs/Registry/CodecEncodePipeline.cs#L66-L102","documentation":"Thrown by CodecEncodePipeline.TryEncodeAsync when the plugin encode to a temp staging file (.ig-save-*) succeeded but File.Move onto the real destination failed. TryPromote reports the underlying exception message instead of throwing directly, so the pipeline wraps it as IOException. The temp file is deleted best-effort on every failure path.","triggerScenarios":"Destination file is locked by another process (image editor, viewer, cloud-sync client, antivirus); destination folder is read-only or the user lacks permission; destination disk is full; destination path is invalid or on an unwritable network share.","commonSituations":"Saving over a file currently being uploaded by OneDrive/Dropbox/Google Drive; saving into a protected system directory; disk full mid-write; antivirus scanning the new file and holding a brief lock.","solutions":["Close any other application that may hold the destination file open, then retry.","Save to a writable temporary location first, then copy/move once the lock is released.","Verify write permission and free disk space on the destination folder.","For cloud-sync folders, pause sync or save outside the sync root and move manually."],"exampleFix":"// before\nawait photo.SaveAsAsync(destFilePath, transform, quality, token);\n\n// after\ntry\n{\n    await photo.SaveAsAsync(destFilePath, transform, quality, token);\n}\ncatch (IOException ex) when (ex.Message.Contains(\"could not finalize\"))\n{\n    var tmp = Path.Combine(Path.GetTempPath(), Path.GetFileName(destFilePath));\n    await photo.SaveAsAsync(tmp, transform, quality, token);\n    File.Copy(tmp, destFilePath, overwrite: true);\n}","handlingStrategy":"retry","validationCode":"var dir = Path.GetDirectoryName(destFilePath);\nif (!Directory.Exists(dir) || !HasWriteAccess(dir))\n    throw new InvalidOperationException(\"Destination folder is not writable.\");\nbool HasWriteAccess(string p) { try { var f = Path.Combine(p, $\".ig-probe-{Guid.NewGuid():N}\"); File.WriteAllText(f, \"\"); File.Delete(f); return true; } catch { return false; } }","typeGuard":null,"tryCatchPattern":"try { await photo.SaveAsAsync(destFilePath, transform, quality, token); }\ncatch (IOException ex) when (ex.Message.Contains(\"could not finalize\"))\n{ await Task.Delay(250); /* retry once, or save to temp then copy */ }","preventionTips":["Close other apps holding the destination file before saving.","Avoid saving directly into active cloud-sync folders; save outside and let sync pick it up.","Verify free disk space and write permission on the destination folder."],"tags":["io","encode","pipeline","file-lock"],"backgroundTag":null,"analyzedSha":"4a3c4feceffc5a8bb5e56ba836509634aaae47a9","analyzedAt":"2026-08-13T16:58:15.523Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}