ソースを参照

Fix accumulating lastModified.

* Also remove redundant check for create or update.
Stefano Cossu 6 年 前
コミット
ef43f7defc
2 ファイル変更6 行追加3 行削除
  1. 1 2
      lakesuperior/api/resource.py
  2. 5 1
      lakesuperior/model/ldpr.py

+ 1 - 2
lakesuperior/api/resource.py

@@ -210,13 +210,12 @@ def create_or_replace(uid, stream=None, **kwargs):
     @return string Event type: whether the resource was created or updated.
     '''
     rsrc = LdpFactory.from_provided(uid, stream=stream, **kwargs)
-    create = not rsrc.is_stored
 
     if not stream and rsrc.is_stored:
         raise InvalidResourceError(rsrc.uid,
                 'Resource {} already exists and no data set was provided.')
 
-    return rsrc.create_or_replace(create_only=create)
+    return rsrc.create_or_replace()
 
 
 @transaction(True)

+ 5 - 1
lakesuperior/model/ldpr.py

@@ -384,9 +384,13 @@ class Ldpr(metaclass=ABCMeta):
         if not create:
             rdfly.truncate_rsrc(self.uid)
 
+        remove_trp = {
+            (self.uri, nsc['fcrepo'].lastModified, None),
+            (self.uri, nsc['fcrepo'].lastModifiedBy, None),
+        }
         add_trp = set(self.provided_imr.graph) | self._containment_rel(create)
 
-        self._modify_rsrc(ev_type, add_trp=add_trp)
+        self._modify_rsrc(ev_type, remove_trp, add_trp)
         new_gr = Graph()
         for trp in add_trp:
             new_gr.add(trp)