Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion wadas/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
# Date: 2024-08-14
# Description: module to keep track of WADAS version

__version__ = "v1.0.0.a2"
__version__ = "v1.0.0.a3"
__dbversion__ = __version__
27 changes: 18 additions & 9 deletions wadas/domain/ftps_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,25 @@ def on_file_received(self, file):

# check if the received file match one of the allowed extensions
# (the check relies on an inspection of the file content)
if (ftype := filetype.guess(file)) and f".{ftype.extension}" in self.ALLOWED_EXTS:
media_queue.put(
{
"media_path": file,
"media_id": pathlib.PurePath(file).parent.name,
"camera_id": self.username,
}
)
ftype = filetype.guess(file)

if ftype:
file_ext = ftype.extension
logger.debug("Extension of received file: %s", file_ext)

if f".{ftype.extension}" in self.ALLOWED_EXTS:
media_queue.put(
{
"media_path": file,
"media_id": pathlib.PurePath(file).parent.name,
"camera_id": self.username,
}
)
else:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can return here, when the file is ok. And move the os.remove(file_) to the end of the function, so that you can avoid doing two times in the "clean-up" phase.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove is also surrounded with error description per case, so I would prefer to keep it as is.

logger.warning("Unsupported file %s. Removing file.", file)
os.remove(file)
else:
logger.warning("Unsupported file %s. Removing file.", file)
logger.warning("Unable to determine file type for %s. Removing file.", file)
os.remove(file)

def on_incomplete_file_received(self, file):
Expand Down
Loading