Skip to content

Commit

Permalink
[cloud][backup][base] If rename failed try to copy then delete source…
Browse files Browse the repository at this point in the history
… if succeeded. MAPSME-15284

If file rename failed (e.g. due to src and dst belongs to different filesystems), then try to copy file from source to dest then delete source if copy succeeded.
  • Loading branch information
tomilov authored and Polas committed Nov 30, 2020
1 parent c24fdaa commit 01d6dab
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions map/cloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1550,8 +1550,12 @@ void Cloud::ApplyRestoredFiles(std::string const & dirPath, RestoredFilesCollect
auto const readyFile = base::JoinPath(m_params.m_restoringFolder, finalFilename);
if (!base::RenameFileX(restoredFile, readyFile))
{
FinishRestoring(SynchronizationResult::DiskError, "Restored file moving error");
return;
if (!base::CopyFileX(restoredFile, readyFile))
{
FinishRestoring(SynchronizationResult::DiskError, "Restored file copying error");
return;
}
UNUSED_VALUE(base::DeleteFileX(restoredFile));
}
readyFiles.emplace_back(readyFile, f.m_hash);
}
Expand Down

0 comments on commit 01d6dab

Please sign in to comment.