-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[WIP] Use exceptions in SFTP backend #13390
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
Conversation
|
It feels wrong if an |
|
@MorrisJobke the way I look at it, is that an exception occurs when something exceptional happens - for example if a function that is to get some property of a file fails to get that property. However, in some circumstances such errors should be ignored (for the greater good), like in cache scanning. An exception while trying to access a file indicates that the file is otherwise unavailable, so in bulk scanning jobs (like As for the |
|
The inspection completed: 6 new issues, 2 updated code elements |
|
@icewind1991 what do you think of this approach? Is there any better way to handle exceptions in the filesystem view layer? |
|
As mentioned in #13791, given that the storage subsystem isn't ready to handle exceptions yet, this needs to be postponed until we have a proper exception handling mechanism in place. |
|
I'd say the minimum would be try and catch the "storage not available" cases and throw these. |
|
@PVince81 @icewind1991 In what direction should we take this? The ultimate goal as I see it is to have exceptions as the error handling mechanism in the filesystem layer, but I understand that at the moment the filesystem doesn't handle exceptions very well. How does this relate to the other filesystem-related PRs, like #11091? Do we want to focus on getting exception-safety for oC 8.2? |
|
I'm not sure, there is already a lot of stuff for 8.2, but we can tentatively set this to 8.2. |
Exceptions are reported for errors instead of returning false. If an exception
occurs during connection, a StorageNotAvailableException is thrown.
This commit also makes the file cache scanner more robust when it comes to
exceptions - there are a few more try {} catch {} blocks in strategic locations
f706955 to
33f30bb
Compare
|
@Xenopathic currently the only exceptions properly caught in core are StorageNotAvailableException and StorageInvalidException. Maybe we should add more like the auth one you proposed ? Regarding catching an exception without handler, please add a comment inside to explain why it is doing nothing. I guess this PR will probably have to wait further. |
|
@PVince81 I had a better idea (I think I discussed it on IRC once): allow a Storage to define exceptions that come from underlying libraries and how to map them to OC exceptions (e.g. SFTP exceptions => StorageNotAvailableException), which can then be handled properly in core. But having the AuthenticationFailedException would be handy to have in core. |
|
That sounds like a plan, have a look at how we did it for DAV storages: https://github.com/owncloud/core/blob/master/lib/private/files/storage/dav.php#L787 Maybe this could be done in a more generic way. |
|
@PVince81 Brilliant! A working implementation of that idea, perfect. For a more generic method, how about each class simply enumerates the exception map as an array, then a generic E.g. Don't know what the performance of that will be... then again, exceptions are exceptional events, not regular or frequent. |
|
That could work. |
|
@PVince81 Yeah, I think we should keep it simple and follow what the DAV storage does, a |
|
Talked to @Xenopathic and we will move this to 9.0 because it would be nice to have this merged early in the development cycle. |
|
@Xenopathic any update? |
|
Needs rebase and probably defer to 9.1 ? |
|
@Xenopathic Is this really needed anymore? I thought there went other fixes into the files_external. If there is no response within the next weeks I will close this, because the underlying code is restructured a lot. 😝 |
|
@MorrisJobke unfortunately no. We still require every external storage backend to properly throw |
|
and with "no", I mean "yes" to you question "Is this really needed anymore?" |
|
@Xenopathic can we move this forward ? |
|
@Xenopathic revive or close ? This PR is more than a year old. |
|
Yeah, close. This would need to be mostly rewritten anyway |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Exceptions are reported for errors instead of returning false. If an exception occurs during connection, a StorageNotAvailableException is thrown. One difference is that files that cannot be accessed will give an 'Unknown error' in the web UI, instead of allowing access to the folder but silently failing on anything inside it. It's not ideal, but better than before IMHO.
This commit also makes the file cache scanner more robust when it comes to exceptions - there are a few more
try {} catch {}blocks in strategic locations.Fixes #13238 (needs tested though!)
cc @icewind1991 @PVince81 @LukasReschke @DeepDiver1975 @MorrisJobke