changeset 929:c20c2eea6fce

another hack to stop graphfile from thinking its own new empty file means it should delete all the statements in that context Ignore-this: 94639afbbe8d3a0abd8a06e16922394f
author Drew Perttula <drewp@bigasterisk.com>
date Tue, 11 Jun 2013 20:25:02 +0000
parents d9fd4725c453
children ba7ff8c1d8f8
files bin/subcomposer light9/rdfdb/graphfile.py
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/bin/subcomposer	Tue Jun 11 20:09:45 2013 +0000
+++ b/bin/subcomposer	Tue Jun 11 20:25:02 2013 +0000
@@ -145,7 +145,7 @@
         addQuads = [(repl(s), p, repl(o), newUri) for s,p,o,c in delQuads]
         # patch can't span contexts yet
         self.graph.patch(Patch(addQuads=addQuads, delQuads=[]))
-        #self.graph.patch(Patch(addQuads=[], delQuads=delQuads))
+        self.graph.patch(Patch(addQuads=[], delQuads=delQuads))
         
         
     def setupSubChoiceLinks(self):
--- a/light9/rdfdb/graphfile.py	Tue Jun 11 20:09:45 2013 +0000
+++ b/light9/rdfdb/graphfile.py	Tue Jun 11 20:25:02 2013 +0000
@@ -29,6 +29,7 @@
             except OSError:
                 pass
             f = open(path, "w")
+            f.write("#new\n")
             f.close()
             iolog.info("%s created", path)
             self.lastWriteTimestamp = os.path.getmtime(path)
@@ -89,6 +90,15 @@
         old = self.getSubgraph(self.uri)
         new = Graph()
         try:
+            contents = open(self.path).read()
+            if contents.startswith("#new"):
+                log.debug("%s ignoring empty contents of my new file", self.path)
+                # this is a new file we're starting, and we should not
+                # patch our graph as if it had just been cleared. We
+                # shouldn't even be here reading this, but
+                # lastWriteTimestamp didn't work.
+                return
+
             new.parse(location=self.path, format='n3')
         except SyntaxError as e:
             print e