Verified Commit c56829c8 authored by Karel Koci's avatar Karel Koci 🤘
Browse files

nsfarm/lxd: fix image hash calculation

The issue here is that we should not use full path to file never to
calculate hash as different location of NSFarm project result in
different hashes and thus we do not share them at all.
This makes one instance where we included full path just relative to
images directory. This way the path should be contant no matter where
the project is located.

This also does small tweak in form of removal of unnecessary
comprehension error. We can convert directly to list without creating
generator.
parent 8197146c
...@@ -85,13 +85,13 @@ class Image: ...@@ -85,13 +85,13 @@ class Image:
self._md5sum_update_file(md5sum, self._file_path) self._md5sum_update_file(md5sum, self._file_path)
# Additional nodes from directory # Additional nodes from directory
if self._dir_path: if self._dir_path:
nodes = [path for path in self._dir_path.iterdir()] nodes = list(self._dir_path.iterdir())
while nodes: while nodes:
node = nodes.pop() node = nodes.pop()
path = self._dir_path / node path = self._dir_path / node
md5sum.update(str(node).encode()) md5sum.update(str(node.relative_to(self.IMGS_DIR)).encode())
if path.is_dir(): if path.is_dir():
nodes += [path for path in node.iterdir()] nodes += list(node.iterdir())
elif path.is_file(): elif path.is_file():
# For plain file include content # For plain file include content
self._md5sum_update_file(md5sum, path) self._md5sum_update_file(md5sum, path)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment