-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
[admin] Fixed FileNotFoundError #140 #180
[admin] Fixed FileNotFoundError #140 #180
Commits on Feb 22, 2022
-
[admin] Fixed FileNotFoundError openwisp#140
The change_view associated with BuildAdmin class was throwing an exception when trying to delete a FirmwareImage object, when the file associated with that object had already been deleted from the file system. There were two tasks according to my understanding: 1. Prevent the website to break and catch the error: the return expression in change_view has been put in a try/catch expression, with instructions/hints/warnings for the user using message_user 2. If an image file has been deleted from the filesystem, automatically remove the FirmwareImage assiciated with it: The 'get_queryset' method for FirmwareImageInline class has been over-written to automatically remove FirmwareImage objects associated with deleted files and the information has been logged with logger. Fixes openwisp#140
Configuration menu - View commit details
-
Copy full SHA for 0e78ce8 - Browse repository at this point
Copy the full SHA 0e78ce8View commit details
Commits on Apr 4, 2022
-
Configuration menu - View commit details
-
Copy full SHA for ba7ac15 - Browse repository at this point
Copy the full SHA ba7ac15View commit details
Commits on Apr 13, 2022
-
Configuration menu - View commit details
-
Copy full SHA for c19f1cd - Browse repository at this point
Copy the full SHA c19f1cdView commit details
Commits on Apr 26, 2022
-
[admin] fixed FileNotFoundError while deleting a FirmwareImage openwi…
…sp#140 I couldn't reproduce this issue with Django's standard `models.FileField` so I figured that the problem is with the way `private_storage` is being used. Strangely, there's no problem when delete method is called on an instance of the model. The error is always thrown when the delete method is called on a "modelForm" for an instance, the image file for which has been deleted. So the issue really is with the `private_storage` module. To get around the error though, what I have done is: - `try` to return change_view - `catch` the `FileNotFoundError` if it occurs - Get the `path` from the error itself - check if the specified directory exists, if not create one - create a temporary file - return `change_view` again (recursion) - This time the file is there to be deleted and the model instance is deleted as well This seems like a "brute force" solution, but since the origin of the issue is an external module, this is the only possible workaround (As we don't want to automatically delete any model instances because it would be strange for the user) Fixes openwisp#140
Configuration menu - View commit details
-
Copy full SHA for a3e1263 - Browse repository at this point
Copy the full SHA a3e1263View commit details -
[admin] fixed FileNotFoundError while deleting a FirmwareImage openwi…
…sp#140 Added a try/catch block in the change_view of `BuildAdmin` class. If a `FileNotFoundError` is caught, the relavant file/directory will be temperorily re-created just before recursively calling change_view again. Fixes openwisp#140
Configuration menu - View commit details
-
Copy full SHA for 739f0a2 - Browse repository at this point
Copy the full SHA 739f0a2View commit details -
[admin] Fixed FileNotFoundError while deleting a FirmwareImage openwi…
…sp#140 Added a try/catch block in the return statement in `BuildAdmin` `change_view` If a `FileNotFoundError` is caught, the file/directory from the error path is recreated temperorily before recursively calling `change_view` again, to complete the delete operation without throwing any errors. Fixes openwisp#140
Configuration menu - View commit details
-
Copy full SHA for ba9e1cf - Browse repository at this point
Copy the full SHA ba9e1cfView commit details