Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
timmo001 committed Jun 10, 2022
2 parents eab6d19 + 731bb0e commit 469412d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions backend/systembridgebackend/server/media.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""System Bridge: Server Handler - Media"""
from __future__ import annotations

import mimetypes
import os

Expand Down Expand Up @@ -39,21 +41,24 @@ def get_files(
path: str,
) -> list[dict]:
"""Get files from path"""
files = []
files_info = []
for filename in os.listdir(path):
files.append(
get_file(BASE_DIRECTORIES[base_path], os.path.join(path, filename))
)
file_info = get_file(BASE_DIRECTORIES[base_path], os.path.join(path, filename))
if file_info is not None:
files_info.append(file_info)

return files
return files_info


def get_file(
base_path: str,
filepath: str,
) -> dict:
) -> dict | None:
"""Get file from path"""
stat = os.stat(filepath)
try:
stat = os.stat(filepath)
except FileNotFoundError:
return None

mime_type = None
if os.path.isfile(filepath):
Expand Down

0 comments on commit 469412d

Please sign in to comment.