{"record":{"id":"9ec09bc1bca5c827","repo":"getgrav/grav","slug":"file-could-not-be-renamed-s-s-s","errorCode":null,"errorMessage":"File could not be renamed: %s -> %s (%s)","messagePattern":"File could not be renamed: (.+?) -> (.+?) \\((.+?)\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":500,"severity":"error","filePath":"system/src/Grav/Common/Media/Traits/MediaUploadTrait.php","lineNumber":541,"sourceCode":"        if (!is_file($fromPath)) {\n            return;\n        }\n\n        $mediaPath = dirname($fromPath);\n        $toPath = $mediaPath . '/' . $to;\n        if ($locator->isStream($toPath)) {\n            $toPath = $locator->findResource($toPath, true, true);\n        }\n\n        if (is_file($toPath)) {\n            // TODO: translate error message\n            throw new RuntimeException(sprintf('File could not be renamed: %s already exists (%s)', $to, $mediaPath), 500);\n        }\n\n        $result = rename($fromPath, $toPath);\n        if (!$result) {\n            // TODO: translate error message\n            throw new RuntimeException(sprintf('File could not be renamed: %s -> %s (%s)', $from, $to, $mediaPath), 500);\n        }\n\n        // TODO: Add missing logic to handle retina files.\n        if (is_file($fromPath . '.meta.yaml')) {\n            $result = rename($fromPath . '.meta.yaml', $toPath . '.meta.yaml');\n            if (!$result) {\n                // TODO: translate error message\n                throw new RuntimeException(sprintf('Meta could not be renamed: %s -> %s (%s)', $from, $to, $mediaPath), 500);\n            }\n        }\n    }\n\n    /**\n     * Internal logic to remove file.\n     *\n     * @param string $filename\n     * @param string $path\n     */","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/getgrav/grav/blob/6040efed04efa69b8209448ed81308e7c24147c2/system/src/Grav/Common/Media/Traits/MediaUploadTrait.php#L523-L559","documentation":"Error \"File could not be renamed: %s -> %s (%s)\" thrown in getgrav/grav.","triggerScenarios":"Thrown at system/src/Grav/Common/Media/Traits/MediaUploadTrait.php:541 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6040efed04efa69b8209448ed81308e7c24147c2","analyzedAt":"2026-08-17T05:07:31.593Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}