changeset 5297:c78138dc3889

When deleting a resource, its parents LastUpdate metadata is now updated
author Alain Mazy <am@osimis.io>
date Mon, 22 May 2023 17:58:06 +0200
parents 5053a10da5a2
children 76dc541c5dda
files NEWS OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp
diffstat 2 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon May 22 15:00:01 2023 +0200
+++ b/NEWS	Mon May 22 17:58:06 2023 +0200
@@ -12,6 +12,7 @@
   - boost 1.82.0
 * Fix orphan files remaining in storage when working with MaximumStorageSize
   (https://discourse.orthanc-server.org/t/issue-with-deleting-incoming-dicoms-when-maximumstoragesize-is-reached/3510)
+* When deleting a resource, its parents LastUpdate metadata is now updated.
 
 
 Version 1.12.0 (2023-04-14)
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp	Mon May 22 15:00:01 2023 +0200
+++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp	Mon May 22 17:58:06 2023 +0200
@@ -2036,6 +2036,24 @@
             remainingAncestor_["RemainingAncestor"]["Path"] = GetBasePath(remainingLevel, remainingPublicId);
             remainingAncestor_["RemainingAncestor"]["Type"] = EnumerationToString(remainingLevel);
             remainingAncestor_["RemainingAncestor"]["ID"] = remainingPublicId;
+
+            { // update the LastUpdate metadata of all parents
+              std::string now = SystemToolbox::GetNowIsoString(true /* use UTC time (not local time) */);
+              ResourcesContent content(true);
+
+              int64_t parentId = 0;
+              if (transaction.LookupResource(parentId, remainingLevel, remainingPublicId))
+              {
+
+                do
+                {
+                  content.AddMetadata(parentId, MetadataType_LastUpdate, now);
+                }
+                while (transaction.LookupParent(parentId, parentId));
+    
+                transaction.SetResourcesContent(content);
+              }
+            }
           }
           else
           {