Mercurial > hg > orthanc-object-storage
diff Common/MoveStorageJob.cpp @ 111:407bd022b0cf
in /move-storage: now detecting if file should be moved or not
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 10 Oct 2023 16:11:18 +0200 |
parents | 8a9207933297 |
children | 3c7e0374f28e |
line wrap: on
line diff
--- a/Common/MoveStorageJob.cpp Tue Oct 10 15:40:36 2023 +0200 +++ b/Common/MoveStorageJob.cpp Tue Oct 10 16:11:18 2023 +0200 @@ -67,7 +67,21 @@ // read from source storage try { - OrthancPlugins::LogInfo("Move attachment: " + sourceStorage->GetNameForLogs() + ": reading attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); + if (sourceStorage->HasFileExists() && !sourceStorage->FileExists(uuid, static_cast<OrthancPluginContentType>(type), cryptoEnabled)) + { + OrthancPlugins::LogInfo("Move attachment: " + sourceStorage->GetNameForLogs() + " " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type) + ", skipping, file is not on the source anymore"); + return true; + } + else if (targetStorage->HasFileExists() && targetStorage->FileExists(uuid, static_cast<OrthancPluginContentType>(type), cryptoEnabled)) + { + OrthancPlugins::LogInfo("Move attachment: " + targetStorage->GetNameForLogs() + " " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type) + ", skipping, file already on the target"); + return true; + } + else + { + OrthancPlugins::LogInfo("Move attachment: " + sourceStorage->GetNameForLogs() + ": reading attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); + } + std::unique_ptr<IStorage::IReader> reader(sourceStorage->GetReaderForObject(uuid.c_str(), static_cast<OrthancPluginContentType>(type), cryptoEnabled)); size_t fileSize = reader->GetSize(); @@ -97,7 +111,7 @@ } } - // everything went well so fare, we can delete from source storage + // everything went well so far, we can delete from source storage if (buffer.size() > 0) { try