Sonarr/Sonarr · error · DestinationAlreadyExistsException
Destination {targetPath} already exists.
Error message
Destination {targetPath} already exists. What it means
Thrown as DestinationAlreadyExistsException by ClearTargetPath when the destination file already exists and the caller did not set overwrite=true. It is a deliberate guard against silently clobbering an existing file during a transfer.
Source
Thrown at src/NzbDrone.Common/Disk/DiskTransferService.cs:378
TryMoveFileVerified(sourcePath, targetPath, originalSize);
return TransferMode.Move;
}
return TransferMode.None;
}
private void ClearTargetPath(string sourcePath, string targetPath, bool overwrite)
{
if (_diskProvider.FileExists(targetPath))
{
if (overwrite)
{
_diskProvider.DeleteFile(targetPath);
}
else
{
throw new DestinationAlreadyExistsException($"Destination {targetPath} already exists.");
}
}
}
private void RollbackPartialMove(string sourcePath, string targetPath)
{
try
{
_logger.Debug("Rolling back incomplete file move [{0}] to [{1}].", sourcePath, targetPath);
WaitForIO();
if (_diskProvider.FileExists(sourcePath))
{
_diskProvider.DeleteFile(targetPath);
}
else
{View on GitHub (pinned to da2284d7ea)
Solutions
- Pass overwrite=true to the transfer call if overwriting is the intended behavior.
- Delete or move the existing destination file before transferring.
- Check _diskProvider.FileExists(targetPath) before invoking the transfer and branch accordingly.
Example fix
// before _diskTransferService.TransferFile(src, dst, TransferMode.Copy); // after _diskTransferService.TransferFile(src, dst, TransferMode.Copy, overwrite: true);
Defensive patterns
Strategy: validation
Validate before calling
if (_diskProvider.FileExists(targetPath))
{
if (!overwrite)
{
// decide: skip, delete, or overwrite
return;
}
_diskProvider.DeleteFile(targetPath);
}
_diskTransferService.TransferFile(sourcePath, targetPath, TransferMode.Copy, overwrite); Try / catch
try
{
_diskTransferService.TransferFile(src, dst, TransferMode.Copy);
}
catch (DestinationAlreadyExistsException)
{
// already imported - skip or resolve conflict
} Prevention
- Check FileExists(targetPath) before transferring and decide explicitly.
- Pass overwrite=true only when clobbering is intended.
- Catch DestinationAlreadyExistsException specifically to treat re-imports as non-fatal.
When it happens
Trigger: TransferFile is invoked with overwrite=false (the default) while a file already exists at targetPath. Any subsequent transfer to a previously-imported media file triggers it.
Common situations: Re-importing an episode that already exists in the library, or a download being moved/copied to a destination that was only partially cleaned up.
Related errors
- Source and destination can't be the same {0}
- File already exists
- Source and destination can't be the same {0}
- Large files still exist in {sourcePath} after folder move, n
- Destination cannot be a child of the source [{0}] => [{1}]
AI-assisted analysis of Sonarr/Sonarr@da2284d7ea (2026-08-13).
Data as JSON: /api/errors/fe5f2b68ad6a9027.
Report an issue: GitHub.