# HG changeset patch # User Sebastien Jodogne # Date 1626276075 -7200 # Node ID 2f35e6b765e5e87d011dda020eb72c4a63543696 # Parent b3957ddd88f1cf05678e2af8eea2c767d7d1049d Fix orphaned attachments if bad revision number is provided diff -r b3957ddd88f1 -r 2f35e6b765e5 NEWS --- 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) ========================== diff -r b3957ddd88f1 -r 2f35e6b765e5 OrthancServer/Sources/ServerContext.cpp --- 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; } }