octobercms/october · error · ApplicationException
editor::lang.filesystem.destination_exists
Error message
editor::lang.filesystem.destination_exists
What it means
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.
Source
Thrown at modules/editor/traits/FileSystemFunctions.php:202
}
foreach ($selectedList as $path) {
if (!$this->validateFileSystemPath($path)) {
throw new ApplicationException(Lang::get('editor::lang.filesystem.invalid_path'));
}
$basename = basename($path);
$originalFullPath = $basePath.'/'.$path;
$newFullPath = rtrim($destinationFullPath, '/').'/'.$basename;
$safeDir = $basePath;
if ($originalFullPath == $newFullPath) {
continue;
}
if ((is_file($originalFullPath) && is_file($newFullPath))
|| (is_dir($originalFullPath) && is_dir($newFullPath))) {
throw new ApplicationException(Lang::get(
'editor::lang.filesystem.destination_exists',
['name' => $basename]
));
}
if (is_file($originalFullPath)) {
if (!@File::move($originalFullPath, $newFullPath)) {
throw new ApplicationException(Lang::get(
'editor::lang.filesystem.error_moving_file',
['file' => $basename]
));
}
}
elseif (is_dir($originalFullPath)) {
if (!@File::copyDirectory($originalFullPath, $newFullPath)) {
throw new ApplicationException(Lang::get(
'editor::lang.filesystem.error_moving_directory',
['dir' => $basename]View on GitHub (pinned to b608633a7e)
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
Example fix
// before: assets/img already contains logo.png
{ "source": ["img/logo.png"], "destination": "img" } // blocked
// after: delete target copy first, or move elsewhere
{ "source": ["img/logo.png"], "destination": "img/archive" } Defensive patterns
Strategy: validation
Validate before calling
$basename = basename($path);
$newFullPath = rtrim($destinationFullPath, '/').'/'.$basename;
$sameType = (is_file($assetsBase.'/'.$path) && is_file($newFullPath))
|| (is_dir($assetsBase.'/'.$path) && is_dir($newFullPath));
if ($sameType) {
// delete/rename the target entry or pick another destination first
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- editor::lang.filesystem.type_not_allowed
- editor::lang.filesystem.error_deleting_dir_not_empty
- editor::lang.filesystem.selected_files_not_found
- editor::lang.filesystem.select_destination_dir
- editor::lang.filesystem.directory_name_cant_be_empty
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/f8a837a501e114e8.
Report an issue: GitHub.