Skip to content

Commit

Permalink
Fixed FileNotFoundErrors with the files in store (#707)
Browse files Browse the repository at this point in the history
* boot the scaffold before/during the topology, so file deps are available

* Fallback mtimes for missing files
  • Loading branch information
Helveg committed Apr 4, 2023
1 parent 78a455b commit e17224f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions bsb/config/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ def default(cls, **kwargs):
return conf

def _bootstrap(self, scaffold):
# Activate the scaffold property of each config node
_boot_nodes(self, scaffold)
self._config_isbooted = True
# Initialise the topology from the defined regions
regions = builtins.list(self.regions.values())
# Arrange the topology based on network boundaries
Expand All @@ -92,9 +95,6 @@ def _bootstrap(self, scaffold):
"__unmanaged__", RegionGroup(children=builtins.list(unmanaged))
)
topology.children.append(r)
# Activate the scaffold property of each config node
_boot_nodes(self, scaffold)
self._config_isbooted = True

def _update_storage_node(self, storage):
if self.storage.engine != storage.format:
Expand Down
10 changes: 9 additions & 1 deletion bsb/storage/_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,15 @@ def find(self, file: FileDependency):
@_abc.abstractmethod
def should_update(self, file: FileDependency, stored_file):
path = _uri_to_path(file.uri)
return _os.path.getmtime(path) > stored_file.mtime
try:
file_mtime = _os.path.getmtime(path)
except FileNotFoundError:
return False
try:
stored_mtime = stored_file.mtime
except Exception:
return True
return file_mtime > stored_mtime

@_abc.abstractmethod
def get_content(self, file: FileDependency):
Expand Down

0 comments on commit e17224f

Please sign in to comment.