-
Notifications
You must be signed in to change notification settings - Fork 1
Ftp server improvement #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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: | ||
stefanodellosa-personal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.