# HG changeset patch # User Drew Perttula # Date 1370982302 0 # Node ID c20c2eea6fce85bc4ad4fb0e7a94cc1993283c39 # Parent d9fd4725c453485671e0ea5b6dca8d0b8b118c57 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 diff -r d9fd4725c453 -r c20c2eea6fce bin/subcomposer --- 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): diff -r d9fd4725c453 -r c20c2eea6fce light9/rdfdb/graphfile.py --- 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