Don't assemble a file if file already exists in a file system (can happen if several files with the same content are simultaneously created)
diff --git a/src/dispatcher.cc b/src/dispatcher.cc
index 1928912..03de6a9 100644
--- a/src/dispatcher.cc
+++ b/src/dispatcher.cc
@@ -371,6 +371,16 @@
file++)
{
boost::filesystem::path filePath = m_rootDir / file->filename ();
+
+ if (filesystem::exists (filePath) &&
+ filesystem::last_write_time (filePath) == file->mtime () &&
+ filesystem::status (filePath).permissions () == static_cast<filesystem::perms> (file->mode ()) &&
+ *Hash::FromFileContent (filePath) == hash)
+ {
+ _LOG_DEBUG ("Asking to assemble a file, but file already exists on a filesystem");
+ continue;
+ }
+
m_objectManager.objectsToLocalFile (deviceName, hash, filePath);
last_write_time (filePath, file->mtime ());