From 03275fe9543213309d06f416faf8363c0a973bcc Mon Sep 17 00:00:00 2001 From: Jason Rush Date: Wed, 30 Oct 2024 16:08:33 -0600 Subject: [PATCH] Misc fixes --- shared/bin/extracted_files_http_server.py | 36 +++++++++++++---------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/shared/bin/extracted_files_http_server.py b/shared/bin/extracted_files_http_server.py index 6a493f932..8ea1e6880 100755 --- a/shared/bin/extracted_files_http_server.py +++ b/shared/bin/extracted_files_http_server.py @@ -147,15 +147,21 @@ def do_GET(self): for dirpath, dirnames, filenames in os.walk(fullpath): # list directories first for dirname in sorted(dirnames, key=natural_sort_key): - child = os.path.join(dirpath, dirname) - if args.links or (not os.path.islink(child)): - items.append(('dir', dirname, child)) + try: + child = os.path.join(dirpath, dirname) + if args.links or (not os.path.islink(child)): + items.append(('dir', dirname, child)) + except Exception as e: + eprint(f'Error with directory "{dirname}"": {e}') # list files for filename in sorted(filenames, key=natural_sort_key): - child = os.path.join(dirpath, filename) - if args.links or (not os.path.islink(child)): - items.append(('file', filename, child)) - # only process the current directory + try: + child = os.path.join(dirpath, filename) + if args.links or (not os.path.islink(child)): + items.append(('file', filename, child)) + except Exception as e: + eprint(f'Error with file "{filename}"": {e}') + # our "walk" is not recursive right now, we only need to go one level deep break totalItems = len(items) @@ -196,12 +202,12 @@ def do_GET(self): t.add(th(), th(), th()) # content rows - for itemType, name, child in itemsOnPage: + for itemType, filename, child in itemsOnPage: try: if itemType == 'dir': t = tr() t.add( - td(a(name, href=f'{name}/?page=1&elements={elements}')), + td(a(filename, href=f'{filename}/?page=1&elements={elements}')), td("Directory"), td(''), ) @@ -211,21 +217,18 @@ def do_GET(self): elif itemType == 'file': t = tr() - filename = name + # calculate some of the stuff for representing Malcolm files timestamp = None timestampStr = '' timestampStartFilterStr = '' fmatch = None fsource = '' fids = list() - if showMalcolmCols: # determine if filename is in a pattern we recognize fmatch = carvedFileRegex.search(filename) - if fmatch is None: fmatch = carvedFileRegexAlt.search(filename) - if fmatch is not None: # format timestamp as ISO date/time timestampStr = fmatch.groupdict().get('timestamp', '') @@ -240,7 +243,6 @@ def do_GET(self): except Exception as te: if timestampStr: eprint(f'Error with time "{str(timestampStr)}": {te}') - # put UIDs and FUIDs into a single event.id-filterable column fids = list( [ @@ -273,7 +275,11 @@ def do_GET(self): t.add( td( a( - (filename[:fnameDispLen] + '...') if len(filename) > fnameDispLen else filename, + ( + (filename[:fnameDispLen] + '...') + if len(filename) > fnameDispLen + else filename + ), href=f'{filename}', ), title=filename,