{"record":{"id":"066edf15bb043267","repo":"octobercms/october","slug":"editor-lang-filesystem-error-moving-directory","errorCode":null,"errorMessage":"editor::lang.filesystem.error_moving_directory","messagePattern":"editor::lang\\.filesystem\\.error_moving_directory","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"modules/editor/traits/FileSystemFunctions.php","lineNumber":218,"sourceCode":"            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]\n                    ));\n                }\n\n                if (strpos($originalFullPath, '../') !== false) {\n                    throw new ApplicationException(Lang::get(\n                        'editor::lang.filesystem.error_deleting_directory',\n                        ['dir' => $basename]\n                    ));\n                }\n\n                if (strpos($originalFullPath, $safeDir) !== 0) {\n                    throw new ApplicationException(Lang::get(\n                        'editor::lang.filesystem.error_deleting_directory',\n                        ['dir' => $basename]\n                    ));\n                }","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/editor/traits/FileSystemFunctions.php#L200-L236","documentation":"Thrown by editorMoveFilesOrDirectories when @File::copyDirectory() fails while moving a directory (lines 216-222). Message: 'Error moving directory :dir'. Directories are moved by copy-then-delete (works across devices), and copyDirectory aborts on the first file that cannot be written — typically the destination is not writable by the PHP user or the disk is full. IMPORTANT: this throws AFTER copying may have partially succeeded, and the original directory is left untouched.","triggerScenarios":"Thrown at modules/editor/traits/FileSystemFunctions.php:218 when the library encounters an invalid state.","commonSituations":"Deep asset trees where the destination was auto-created with different ownership; low disk space on the theme volume; one locked/unreadable file inside the tree aborting the whole copy; retries after partial copies leaving duplicated content.","solutions":["Make the destination directory writable by the PHP user (chown/chmod -R), then retry and clean up any partial copy","Check disk space (df -h) and free space if full","Identify unreadable files inside the source tree (permissions on individual files) and fix them","After any failed dir move, compare source and destination trees and delete the partial copy before retrying"],"exampleFix":"# before: partial copy left in destination\n$ sudo rm -rf themes/demo/assets/img/archive-lib\n$ sudo chown -R www-data:www-data themes/demo/assets/img\n# retry the move — full tree now copies, original is deleted after","handlingStrategy":"try-catch","validationCode":"if (!is_writable($destinationFullPath) || disk_free_space($assetsBase) < $expectedTreeSize) {\n    // dir moves are copy+delete: destination must be writable AND disk must fit the tree\n}","typeGuard":null,"tryCatchPattern":"use October\\Rain\\Exception\\ApplicationException;\n\ntry {\n    if (!@File::copyDirectory($originalFullPath, $newFullPath)) {\n        throw new ApplicationException(Lang::get('editor::lang.filesystem.error_moving_directory', ['dir' => $basename]));\n    }\n} catch (ApplicationException $e) {\n    // original tree is intact; remove the partial copy before any retry\n    @File::deleteDirectory($newFullPath);\n    throw $e;\n}","preventionTips":["Remember directory moves copy first — always delete partial copies after failures","Keep destinations writable and disks above a healthy free-space margin","Fix permissions on individual files inside large trees before moving them"],"tags":["filesystem","permissions","disk-space","io","editor","winter-cms"],"backgroundTag":"filesystem-permission-denied","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}