[bin] meshroom_photogrammetry: setup cache folder according to --save path

except if --cache is set explicitly
This commit is contained in:
Fabien Castan 2019-09-12 21:36:36 +02:00
parent ee2fc63bd5
commit 979ee4ba94
2 changed files with 16 additions and 8 deletions

View file

@ -905,7 +905,7 @@ class Graph(BaseObject):
def asString(self):
return str(self.toDict())
def save(self, filepath=None):
def save(self, filepath=None, fileLink=True):
path = filepath or self._filepath
if not path:
raise ValueError("filepath must be specified for unsaved files.")
@ -929,7 +929,7 @@ class Graph(BaseObject):
with open(path, 'w') as jsonFile:
json.dump(data, jsonFile, indent=4)
if path != self._filepath:
if path != self._filepath and fileLink:
self._setFilepath(path)
def _setFilepath(self, filepath):
@ -939,7 +939,9 @@ class Graph(BaseObject):
Args:
filepath: the graph file path
"""
assert os.path.isfile(filepath)
if not os.path.isfile(filepath):
self._unsetFilepath()
return
if self._filepath == filepath:
return
@ -951,6 +953,12 @@ class Graph(BaseObject):
self.cacheDir = os.path.join(os.path.abspath(os.path.dirname(filepath)), meshroom.core.cacheFolderName)
self.filepathChanged.emit()
def _unsetFilepath(self):
self._filepath = ""
self.name = ""
self.cacheDir = meshroom.core.defaultCacheFolder
self.filepathChanged.emit()
def updateInternals(self, startNodes=None, force=False):
nodes, edges = self.dfsOnFinish(startNodes=startNodes)
for node in nodes: