file_manager: scan metadata for renamed gcode files

Some slicers create a temporary file during export, then rename the file with gcode extension after completion.  If file metadata does not exist during an attempt to move metadata, scan the file.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2021-06-08 16:55:04 -04:00
parent b16110bcd0
commit 0b885ec5ec
1 changed files with 4 additions and 3 deletions

View File

@ -1090,7 +1090,7 @@ class INotifyHandler:
self.gcode_metadata.move_directory_metadata(
prev_rel_path, new_rel_path)
else:
self.gcode_metadata.move_file_metadata(
return self.gcode_metadata.move_file_metadata(
prev_rel_path, new_rel_path)
else:
# move from a non-gcodes root to gcodes root needs a rescan
@ -1440,11 +1440,11 @@ class MetadataStorage:
prev_fname: str,
new_fname: str,
move_thumbs: bool = True
) -> None:
) -> bool:
metadata: Optional[Dict[str, Any]]
metadata = self.mddb.pop(prev_fname, None)
if metadata is None:
return
return False
self.mddb[new_fname] = metadata
prev_dir = os.path.dirname(os.path.join(self.gc_path, prev_fname))
new_dir = os.path.dirname(os.path.join(self.gc_path, new_fname))
@ -1464,6 +1464,7 @@ class MetadataStorage:
except Exception:
logging.debug(f"Error moving thumb from {thumb_path}"
f" to {new_path}")
return True
def parse_metadata(self,
fname: str,