file_manager: initialize "print_start_time" and "job_id" fields in metadata

These fields will be updated by the [history] module.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-03-16 19:26:56 -04:00
parent 94ed9fbd7f
commit 06a07f09e5
1 changed files with 8 additions and 2 deletions

View File

@ -627,7 +627,7 @@ class FileManager:
METADATA_PRUNE_TIME = 600000
METADATA_NAMESPACE = "gcode_metadata"
METADATA_VERSION = 2
METADATA_VERSION = 3
class MetadataStorage:
def __init__(self, server, gc_path, database):
@ -727,7 +727,12 @@ class MetadataStorage:
else:
break
else:
self.mddb[fname] = {'size': fsize, 'modified': modified}
self.mddb[fname] = {
'size': fsize,
'modified': modified,
'print_start_time': None,
'job_id': None
}
logging.info(
f"Unable to extract medatadata from file: {fname}")
evt.set()
@ -754,6 +759,7 @@ class MetadataStorage:
if not metadata:
# This indicates an error, do not add metadata for this
raise self.server.error("Unable to extract metadata")
metadata.update({'print_start_time': None, 'job_id': None})
self.mddb[path] = dict(metadata)
metadata['filename'] = path
if notify: