Mercurial > hg > orthanc
comparison OrthancServer/Sources/ServerContext.cpp @ 5529:acdb8d78bf99
Whatever the SQL error that happens while inserting an instance in DB, remove the attachments that have been added to avoid orphan files
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 06 Feb 2024 15:32:54 +0100 |
parents | b74543e7ac2e |
children | b0b5546f1b9f f7adfb22e20e |
comparison
equal
deleted
inserted
replaced
5528:b822dcebf9ff | 5529:acdb8d78bf99 |
---|---|
720 catch (OrthancException& ex) | 720 catch (OrthancException& ex) |
721 { | 721 { |
722 if (ex.GetErrorCode() == ErrorCode_DuplicateResource) | 722 if (ex.GetErrorCode() == ErrorCode_DuplicateResource) |
723 { | 723 { |
724 LOG(WARNING) << "Duplicate instance, deleting the attachments"; | 724 LOG(WARNING) << "Duplicate instance, deleting the attachments"; |
725 | 725 } |
726 accessor.Remove(dicomInfo); | 726 else |
727 | 727 { |
728 if (dicomUntilPixelData.IsValid()) | 728 LOG(ERROR) << "Unexpected error while storing an instance in DB, cancelling and deleting the attachments: " << ex.GetDetails(); |
729 { | 729 } |
730 accessor.Remove(dicomUntilPixelData); | 730 |
731 } | 731 accessor.Remove(dicomInfo); |
732 } | 732 |
733 | 733 if (dicomUntilPixelData.IsValid()) |
734 { | |
735 accessor.Remove(dicomUntilPixelData); | |
736 } | |
737 | |
734 throw; | 738 throw; |
735 } | 739 } |
736 | 740 |
737 // Only keep the metadata for the "instance" level | 741 // Only keep the metadata for the "instance" level |
738 dicom.ClearMetadata(); | 742 dicom.ClearMetadata(); |