file_manager: fix bug in _handle_metadata_request()
Don't modify the metadata directly. Create a copy, then add the "filename" item. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
73cbcb7b7e
commit
8bd6e45303
|
@ -106,8 +106,8 @@ class FileManager:
|
||||||
|
|
||||||
async def _handle_metadata_request(self, path, method, args):
|
async def _handle_metadata_request(self, path, method, args):
|
||||||
requested_file = args.get('filename')
|
requested_file = args.get('filename')
|
||||||
metadata = self.gcode_metadata.get(requested_file)
|
metadata = dict(self.gcode_metadata.get(requested_file, {}))
|
||||||
if metadata is None:
|
if not metadata:
|
||||||
raise self.server.error(
|
raise self.server.error(
|
||||||
f"Metadata not available for <{requested_file}>", 404)
|
f"Metadata not available for <{requested_file}>", 404)
|
||||||
metadata['filename'] = requested_file
|
metadata['filename'] = requested_file
|
||||||
|
@ -480,7 +480,7 @@ class FileManager:
|
||||||
filename = filename[7:]
|
filename = filename[7:]
|
||||||
|
|
||||||
flist = self.get_file_list()
|
flist = self.get_file_list()
|
||||||
return self.gcode_metadata.get(filename, flist.get(filename, {}))
|
return dict(self.gcode_metadata.get(filename, flist.get(filename, {})))
|
||||||
|
|
||||||
def list_dir(self, directory, simple_format=False):
|
def list_dir(self, directory, simple_format=False):
|
||||||
# List a directory relative to its root. Currently the only
|
# List a directory relative to its root. Currently the only
|
||||||
|
|
Loading…
Reference in New Issue