{"record":{"id":"f8a837a501e114e8","repo":"octobercms/october","slug":"editor-lang-filesystem-destination-exists","errorCode":null,"errorMessage":"editor::lang.filesystem.destination_exists","messagePattern":"editor::lang\\.filesystem\\.destination_exists","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"modules/editor/traits/FileSystemFunctions.php","lineNumber":202,"sourceCode":"        }\n\n        foreach ($selectedList as $path) {\n            if (!$this->validateFileSystemPath($path)) {\n                throw new ApplicationException(Lang::get('editor::lang.filesystem.invalid_path'));\n            }\n\n            $basename = basename($path);\n            $originalFullPath = $basePath.'/'.$path;\n            $newFullPath = rtrim($destinationFullPath, '/').'/'.$basename;\n            $safeDir = $basePath;\n\n            if ($originalFullPath == $newFullPath) {\n                continue;\n            }\n\n            if ((is_file($originalFullPath) && is_file($newFullPath))\n                || (is_dir($originalFullPath) && is_dir($newFullPath))) {\n                throw new ApplicationException(Lang::get(\n                    'editor::lang.filesystem.destination_exists',\n                    ['name' => $basename]\n                ));\n            }\n\n            if (is_file($originalFullPath)) {\n                if (!@File::move($originalFullPath, $newFullPath)) {\n                    throw new ApplicationException(Lang::get(\n                        'editor::lang.filesystem.error_moving_file',\n                        ['file' => $basename]\n                    ));\n                }\n            }\n            elseif (is_dir($originalFullPath)) {\n                if (!@File::copyDirectory($originalFullPath, $newFullPath)) {\n                    throw new ApplicationException(Lang::get(\n                        'editor::lang.filesystem.error_moving_directory',\n                        ['dir' => $basename]","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/editor/traits/FileSystemFunctions.php#L184-L220","documentation":"Thrown by editorMoveFilesOrDirectories when the destination already contains an entry with the same name AND same type as the item being moved (is_file+is_file or is_dir+is_dir, lines 200-206). Message: 'File or directory with this name already exists: :name'. Moving an item onto its own location is skipped silently (originalFullPath == newFullPath continue), so this is specifically a genuine collision at the target.","triggerScenarios":"command_onAssetMove of 'img/logo.png' into a directory that already has 'img/logo.png'; moving folder 'js/lib' into a destination containing a 'js/lib' folder. Note the type must match: a same-named FILE where you move a DIRECTORY passes this check and fails later with error_moving_directory.","commonSituations":"Repeating a move after a previous partial success (copy-based dir moves can leave duplicates); forgetting an earlier move placed the same asset in the target; two sessions moving the same asset to the same folder.","solutions":["Delete or rename the colliding entry in the destination, then retry the move","Choose a different destination directory for the move","Refresh both trees — the collision may come from a stale view of the destination","After interrupted directory moves, compare source and destination copies and clean up duplicates before retrying"],"exampleFix":"// before: assets/img already contains logo.png\n{ \"source\": [\"img/logo.png\"], \"destination\": \"img\" } // blocked\n// after: delete target copy first, or move elsewhere\n{ \"source\": [\"img/logo.png\"], \"destination\": \"img/archive\" }","handlingStrategy":"validation","validationCode":"$basename = basename($path);\n$newFullPath = rtrim($destinationFullPath, '/').'/'.$basename;\n$sameType = (is_file($assetsBase.'/'.$path) && is_file($newFullPath))\n    || (is_dir($assetsBase.'/'.$path) && is_dir($newFullPath));\nif ($sameType) {\n    // delete/rename the target entry or pick another destination first\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check the destination listing for same-named entries before dropping","After failed/interrupted moves, clean partial copies before retrying","Remember only same-type collisions are blocked here — mixed types fail later at the IO step"],"tags":["filesystem","file-exists","validation","editor","winter-cms"],"backgroundTag":"file-already-exists","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}