Mercurial > hg > orthanc
changeset 4752:2f35e6b765e5
Fix orphaned attachments if bad revision number is provided
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 14 Jul 2021 17:21:15 +0200 |
parents | b3957ddd88f1 |
children | c95e4a1e65ed 70d94dcac60c |
files | NEWS OrthancServer/Sources/ServerContext.cpp |
diffstat | 2 files changed, 22 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Thu Jul 08 17:31:03 2021 +0200 +++ b/NEWS Wed Jul 14 17:21:15 2021 +0200 @@ -6,6 +6,11 @@ * Clicking on "Send to remote modality" displays the job information to monitor progress +Maintenance +----------- + +* Fix orphaned attachments if bad revision number is provided + Version 1.9.5 (2021-07-08) ==========================
--- a/OrthancServer/Sources/ServerContext.cpp Thu Jul 08 17:31:03 2021 +0200 +++ b/OrthancServer/Sources/ServerContext.cpp Wed Jul 14 17:21:15 2021 +0200 @@ -1174,16 +1174,25 @@ StorageAccessor accessor(area_, GetMetricsRegistry()); FileInfo attachment = accessor.Write(data, size, attachmentType, compression, storeMD5_); - StoreStatus status = index_.AddAttachment( - newRevision, attachment, resourceId, hasOldRevision, oldRevision, oldMD5); - if (status != StoreStatus_Success) + try { + StoreStatus status = index_.AddAttachment( + newRevision, attachment, resourceId, hasOldRevision, oldRevision, oldMD5); + if (status != StoreStatus_Success) + { + accessor.Remove(attachment); + return false; + } + else + { + return true; + } + } + catch (OrthancException&) + { + // Fixed in Orthanc 1.9.6 accessor.Remove(attachment); - return false; - } - else - { - return true; + throw; } }