Properly refresh analysis data on re-upload of a file
This commit is contained in:
parent
76b4a45495
commit
1b1148d0c6
2 changed files with 8 additions and 4 deletions
|
|
@ -513,7 +513,7 @@ class FileManager(object):
|
|||
return
|
||||
|
||||
storage_manager = self._storage_managers[destination]
|
||||
storage_manager.set_additional_metadata(path, "analysis", result)
|
||||
storage_manager.set_additional_metadata(path, "analysis", result, overwrite=True)
|
||||
|
||||
def _on_analysis_finished(self, entry, result):
|
||||
self._add_analysis_result(entry.location, entry.path, result)
|
||||
|
|
|
|||
|
|
@ -577,8 +577,15 @@ class LocalFileStorage(StorageInterface):
|
|||
# save the file's hash to the metadata of the folder
|
||||
file_hash = self._create_hash(file_path)
|
||||
metadata = self._get_metadata_entry(path, name, default=dict())
|
||||
metadata_dirty = False
|
||||
if not "hash" in metadata or metadata["hash"] != file_hash:
|
||||
metadata["hash"] = file_hash
|
||||
metadata_dirty = True
|
||||
if "analysis" in metadata:
|
||||
del metadata["analysis"]
|
||||
metadata_dirty = True
|
||||
|
||||
if metadata_dirty:
|
||||
self._update_metadata_entry(path, name, metadata)
|
||||
|
||||
# process any links that were also provided for adding to the file
|
||||
|
|
@ -680,9 +687,6 @@ class LocalFileStorage(StorageInterface):
|
|||
new_data = octoprint.util.dict_merge(current_data, data)
|
||||
metadata[name][key] = new_data
|
||||
metadata_dirty = True
|
||||
elif key in metadata[name] and overwrite:
|
||||
metadata[name][key] = data
|
||||
metadata_dirty = True
|
||||
|
||||
if metadata_dirty:
|
||||
self._save_metadata(path, metadata)
|
||||
|
|
|
|||
Loading…
Reference in a new issue