{"record":{"id":"faf42ebe405249cd","repo":"Radarr/Radarr","slug":"source-and-destination-can-t-be-the-same-0","errorCode":null,"errorMessage":"Source and destination can't be the same {0}","messagePattern":"Source and destination can't be the same (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/NzbDrone.Common/Disk/DiskProviderBase.cs","lineNumber":238,"sourceCode":"\n        public void DeleteFile(string path)\n        {\n            Ensure.That(path, () => path).IsValidPath(PathValidationType.CurrentOs);\n            Logger.Trace(\"Deleting file: {0}\", path);\n\n            RemoveReadOnly(path);\n\n            File.Delete(path);\n        }\n\n        public void CloneFile(string source, string destination, bool overwrite = false)\n        {\n            Ensure.That(source, () => source).IsValidPath(PathValidationType.CurrentOs);\n            Ensure.That(destination, () => destination).IsValidPath(PathValidationType.CurrentOs);\n\n            if (source.PathEquals(destination))\n            {\n                throw new IOException(string.Format(\"Source and destination can't be the same {0}\", source));\n            }\n\n            CloneFileInternal(source, destination, overwrite);\n        }\n\n        protected virtual void CloneFileInternal(string source, string destination, bool overwrite = false)\n        {\n            CopyFileInternal(source, destination, overwrite);\n        }\n\n        public void CopyFile(string source, string destination, bool overwrite = false)\n        {\n            Ensure.That(source, () => source).IsValidPath(PathValidationType.CurrentOs);\n            Ensure.That(destination, () => destination).IsValidPath(PathValidationType.CurrentOs);\n\n            if (source.PathEquals(destination))\n            {\n                throw new IOException(string.Format(\"Source and destination can't be the same {0}\", source));","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/Radarr/Radarr/blob/ca451608dc60c6cec754aba8d96bfa30e9468ed5/src/NzbDrone.Common/Disk/DiskProviderBase.cs#L220-L256","documentation":"CloneFile refuses to operate when source.PathEquals(destination). Cloning a file onto itself would be a destructive no-op, so an IOException is thrown. PathEquals normalizes case per OS rules, so on Windows a case-only difference may also trip this.","triggerScenarios":"Caller computes a destination that resolves to the same path as the source; case-only rename on a case-insensitive filesystem where PathEquals already treats them as equal; bug in path-joining logic producing target == source.","commonSituations":"Episode already at the desired path so the clone target equals source; renaming routine that does not short-circuit the no-op case; Windows case-only rename attempts.","solutions":["Normalize both paths with Path.GetFullPath and compare before calling — skip if equal","For case-only renames on case-insensitive FS, rename via a temporary intermediate name","Fix the caller that produced equal source and destination","If the no-op is expected, short-circuit and return success instead of calling CloneFile"],"exampleFix":"// before\n_diskProvider.CloneFile(source, destination);\n\n// after\nif (Path.GetFullPath(source) == Path.GetFullPath(destination))\n{\n    return; // already at target\n}\n_diskProvider.CloneFile(source, destination);","handlingStrategy":"validation","validationCode":"if (Path.GetFullPath(source) == Path.GetFullPath(destination))\n{\n    return; // no-op clone, skip\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    _diskProvider.CloneFile(source, destination, overwrite);\n}\ncatch (IOException ex) when (ex.Message.Contains(\"can't be the same\"))\n{\n    // source == destination; treat as success\n}","preventionTips":["Normalize and compare paths in the caller before any clone/copy/move","Short-circuit no-op renames instead of relying on the guard","For case-only renames use a temp intermediate name"],"tags":["filesystem","io","file-transfer","disk-provider"],"backgroundTag":null,"analyzedSha":"ca451608dc60c6cec754aba8d96bfa30e9468ed5","analyzedAt":"2026-08-13T17:21:54.115Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}