{"record":{"id":"6b4dd7d6deb4b380","repo":"OrchardCMS/OrchardCore","slug":"cannot-copy-file-srcpath-because-it-does-not-exist-6b4dd7","errorCode":null,"errorMessage":"Cannot copy file '{srcPath}' because it does not exist.","messagePattern":"Cannot copy file '(.+?)' because it does not exist\\.","errorType":"exception","errorClass":"FileStoreException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs","lineNumber":593,"sourceCode":"            throw new FileStoreException($\"Cannot move file '{oldPath}' to '{newPath}'.\", ex);\n        }\n    }\n\n    public async Task CopyFileAsync(string srcPath, string dstPath)\n    {\n        try\n        {\n            if (srcPath == dstPath)\n            {\n                throw new ArgumentException($\"The values for {nameof(srcPath)} and {nameof(dstPath)} must not be the same.\");\n            }\n\n            var oldBlob = GetBlobReference(srcPath);\n            var newBlob = GetBlobReference(dstPath);\n\n            if (!await oldBlob.ExistsAsync())\n            {\n                throw new FileStoreException($\"Cannot copy file '{srcPath}' because it does not exist.\");\n            }\n\n            if (await newBlob.ExistsAsync())\n            {\n                throw new FileStoreException($\"Cannot copy file '{srcPath}' because a file already exists in the new path '{dstPath}'.\");\n            }\n\n            await newBlob.StartCopyFromUriAsync(oldBlob.Uri);\n\n            await Task.Delay(250);\n            var properties = await newBlob.GetPropertiesAsync();\n\n            while (properties.Value.CopyStatus == CopyStatus.Pending)\n            {\n                await Task.Delay(250);\n\n                // Need to fetch properties or CopyStatus will never update.\n                properties = await newBlob.GetPropertiesAsync();","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs#L575-L611","documentation":"CopyFileAsync checks that the source blob exists before copying and throws FileStoreException naming the source path when it does not. Blob references are lazy in the Azure SDK, so a missing file only surfaces at this explicit ExistsAsync check.","triggerScenarios":"Calling IFileStore.CopyFileAsync(srcPath, dstPath) when no blob exists under the source path (wrong path, file deleted externally, or typo including case, since blob names are case-sensitive).","commonSituations":"Media items referencing files deleted outside the app; stale database records pointing at renamed files; case-mismatched paths; wrong container/base prefix configuration.","solutions":["Verify the source path with FileExistsAsync before copying and handle the miss gracefully.","Fix the stored path/reference that points to a nonexistent blob.","Check container name and BasePath configuration if all copies fail.","Match the blob name exactly as stored, including casing."],"exampleFix":"// before\nawait _fileStore.CopyFileAsync(srcPath, dstPath);\n// after\nif (!await _fileStore.FileExistsAsync(srcPath))\n{\n    _logger.LogWarning(\"Source file {Src} not found; skipping copy\", srcPath);\n    return;\n}\nawait _fileStore.CopyFileAsync(srcPath, dstPath);","handlingStrategy":"validation","validationCode":"if (!await _fileStore.FileExistsAsync(srcPath))\n{\n    _logger.LogWarning(\"Source {Src} missing; skipping copy\", srcPath);\n    return;\n}\nawait _fileStore.CopyFileAsync(srcPath, dstPath);","typeGuard":null,"tryCatchPattern":"try\n{\n    await _fileStore.CopyFileAsync(srcPath, dstPath);\n}\ncatch (FileStoreException ex) when (ex.Message.Contains(\"does not exist\"))\n{\n    _logger.LogWarning(\"Copy skipped: source {Src} not found\", srcPath);\n}","preventionTips":["Verify stored file references against the store before use (detect orphans).","Blob paths are case-sensitive; preserve exact casing from the store.","Double-check container and BasePath settings when many copies fail.","Handle external deletions gracefully in media cleanup jobs."],"tags":["azure-blob","file-storage","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}