-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Introduce public storage class for extending #26675
Conversation
6ca24d8
to
5b2dc36
Compare
Tested with this PR owncloud/files_external_ftp#11 from the FTP app. To make it a bit better I'll also make the storages from files_external extend that one. |
5b2dc36
to
eda8081
Compare
Ok, done. The storages from files_external now extend |
We should define the abstract methods required to be implemented, first in OC\Files\Storage\Common and then in the public adapter. That way is way easier for anyone to know what he should implement. It's REALLY annoying creating a new subclass, implementing a couple of methods and when you consider it's finally ready then you notice that an additional method should be implemented because the class explodes. |
@jvillafanez do you mean checking all abstract methods from the interface and redefine these as abstract within the StorageAdapter class ? Indeed, the Common class doesn't implement ALL the methods, there are still a few remaining... (me really longing for a better simplified storage API in the future) |
Yes. In case of the There is also a weird inheritance chain: if you want to implement the new public storage, you have to check the Common class, which is private, and then the interface, which is public again. Maybe the Common class should be moved to the public library.... I think it would be better if the abstract classes define the list of abstract methods and they also document how they should be implemented. That way, just looking at the class, you have all the information you need to implement the class. |
Ok, I'll do that short term. Middle to long term we should probably move all methods from |
eda8081
to
cf6aef6
Compare
@jvillafanez I've added the abstract methods that a storage must implement in |
Okay, the code checker wants me to add |
cf6aef6
to
3fce43c
Compare
The only thing I miss is the expected exceptions the methods are supposed to throw. The rest is really nice!!. Should we include some documentation of common methods that might be overwritten for performance? I'm thinking about the rename, isReadable, isCreatable, etc. |
Ahem ahem, there are no expected exceptions in this API... 😢 As for the docs, we could extend what I already posted to mention best practices when implementing an ext storage: owncloud-archive/documentation#2728 |
At least that is being taken into account I think. The problem is that if nobody tells you that you should throw an If there is no expected exceptions, throwing that exception is conceptually wrong 😢 |
In the long term I hope we can redefine the storage APIs completely to be more simply and base them on our own concept (#22388 (comment)), not mimic PHP's system functions, which means exceptions for any errors. @jvillafanez do you want me to add |
If it's being handled I think it's good to have it documented |
@jvillafanez added here 4208efc I took the opportunity to also add these on the |
* @since 9.0.0 | ||
*/ | ||
public function isSharable($path); | ||
|
||
/** | ||
* get the full permissions of a path. | ||
* Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php | ||
* @throws StorageNotAvailableException if the storage is temporarily not available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my copy-paste skills have failed me 😢
Other than that, 👍 |
When writing external storage it is complicated to reimplement IStorage and many others. This PR provides public classes to be extended to provider storage specific implementations.
4208efc
to
c72c159
Compare
Fixed and squashed |
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. |
Description
When writing external storage it is complicated to reimplement IStorage
and many others. This PR provides public classes to be extended to
provider storage specific implementations.
Related Issue
Because apps need to be able to extend the common storage class or use the flysystem adapter without accessing the private namespaces.
Also see owncloud-archive/documentation#2721
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist:
@DeepDiver1975 @jvillafanez @labkode FYI