{"record":{"id":"15367db10c5eeb48","repo":"invoke-ai/InvokeAI","slug":"destination-image-already-exists-move-new-path","errorCode":null,"errorMessage":"Destination image already exists: {move.new_path}","messagePattern":"Destination image already exists: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"invokeai/app/services/image_moves/image_moves_default.py","lineNumber":435,"sourceCode":"                    str(move.old_path),\n                    str(move.new_path),\n                    str(move.old_thumbnail_path),\n                    str(move.new_thumbnail_path),\n                    message,\n                ),\n            )\n            return job_id\n\n    def preflight_moves(self, moves: Sequence[PlannedImageMove]) -> None:\n        destinations: set[Path] = set()\n        thumbnail_destinations: set[Path] = set()\n        for move in moves:\n            if not move.old_path.exists():\n                if not move.is_intermediate:\n                    raise FileNotFoundError(f\"Source image does not exist: {move.old_path}\")\n                continue\n            if move.new_path.exists():\n                raise FileExistsError(f\"Destination image already exists: {move.new_path}\")\n            if move.old_path == move.new_path:\n                raise ValueError(f\"Old and new paths are identical for {move.image_name}\")\n            if move.new_path in destinations:\n                raise ValueError(f\"Duplicate destination path: {move.new_path}\")\n            destinations.add(move.new_path)\n            if move.new_thumbnail_path in thumbnail_destinations:\n                raise ValueError(f\"Duplicate destination thumbnail path: {move.new_thumbnail_path}\")\n            thumbnail_destinations.add(move.new_thumbnail_path)\n            if self._has_active_job_for_image(move.image_name):\n                raise ValueError(f\"Image {move.image_name} already has an active image move job\")\n            self._assert_same_filesystem(move.old_path, move.new_path)\n            if move.old_thumbnail_path.exists():\n                if move.new_thumbnail_path.exists():\n                    raise FileExistsError(f\"Destination thumbnail already exists: {move.new_thumbnail_path}\")\n                self._assert_same_filesystem(move.old_thumbnail_path, move.new_thumbnail_path)\n\n    def _record_missing_source_errors(self, moves: Sequence[PlannedImageMove]) -> tuple[list[PlannedImageMove], int]:\n        remaining_moves: list[PlannedImageMove] = []","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/image_moves/image_moves_default.py#L417-L453","documentation":"preflight_moves raises FileExistsError when the destination image path already exists on disk, preventing an overwrite of user data by the move operation. The check runs only when the source exists, and before the move is recorded.","triggerScenarios":"Re-running a move after a previous run already copied/moved files to the destination; two images resolving to the same destination name via path collisions; destination folder seeded externally with same-named files.","commonSituations":"Retrying a partially-completed move without recovery; importing images into a folder that already contains same-named outputs; case-insensitive filesystems colliding names that differ only by case.","solutions":["Run startup_recovery/complete_partial_filesystem_moves to finish or reconcile the earlier job instead of re-planning","Choose a different destination subfolder or rename to avoid the collision","Remove or rename the pre-existing destination file if it is safe to discard","Detect and skip already-moved images in the caller before planning"],"exampleFix":"// before\nservice.preflight_moves(moves)  # FileExistsError\n// after\nmoves = [m for m in moves if not m.new_path.exists()]\nif moves:\n    service.preflight_moves(moves)","handlingStrategy":"validation","validationCode":"conflicts = [m for m in moves if m.old_path.exists() and m.new_path.exists()]\nif conflicts:\n    raise FileExistsError(f\"destinations exist: {[str(m.new_path) for m in conflicts]}\")\nservice.preflight_moves(moves)","typeGuard":"def destination_free(move: PlannedImageMove) -> bool:\n    return not move.new_path.exists()","tryCatchPattern":"try:\n    service.preflight_moves(moves)\nexcept FileExistsError as e:\n    run_startup_recovery_or_choose_new_destination(e)","preventionTips":["Reconcile partially-completed moves via recovery instead of blind retries","Check destination occupancy before choosing target folders","Be careful with case-insensitive filesystems when generating names"],"tags":["filesystem","file-exists","image-move","preflight"],"backgroundTag":"destination-already-exists","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}