-
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
New Cacheable Flysystem Adapter #29077
New Cacheable Flysystem Adapter #29077
Conversation
Note: the Travis-CI UI test jobs that make use of SauceLabs fail because they do not have any SauceLabs credentials. This is because the PR has come from a forked repo. Only PRs coming from the "master" ownCloud core repo have access to the ownCloud SauceLabs credentials, which are stored securely in the ownCloud Travis-CI account. |
$this->cacheContents[$location] = $this->flysystem->getMetadata($location); | ||
} catch (FileNotFoundException $e) { | ||
// do not store this info in cache as it might interfere with Upload process | ||
return false; |
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.
indentation
b3c9abd
to
5a5263c
Compare
|
||
public function buildPath($path) { | ||
$location = parent::buildPath($path); | ||
if ($this->isCaseInsensitiveStorage) { |
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.
ewww, is that a thing in Dropbox ?!
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.
Yes unfortunately it is
Suppose you have the following directory structure
Foo/
├── bar
│ ├── foo.txt
│ └── some_another_file.txt
└── somefile.txt
In one case dropbox api was returning the folder name Foo as both Foo and foo due to which the directory list of the folder Foo was coming as empty but in reality it was not
* Check if Cache Contains the data for given path, if not then get the data | ||
* from flysystem and store it in cache for this request lifetime | ||
* | ||
* @param string $path Path to file/folder |
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.
document $overRideCache
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.
done see below this line
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.
See comments above, more to come
try { | ||
$this->cacheContents[$location] = $this->flysystem->getMetadata($location); | ||
} catch (FileNotFoundException $e) { | ||
// do not store this info in cache as it might interfere with Upload process |
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.
We should look into storing this info at some point. I know it works because we do this for other storages like DAV.
Maybe the upload interference is a missing stat clear in another place in the code.
I suggest to look into this separately.
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.
Yes i faced some problem with upload process if i stored the info that file is not present in storage. i don't remember exactly what it was
* Public Cacheable storage adapter to be extended to connect to | ||
* flysystem adapters | ||
* | ||
* @since 10.0.x |
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.
make that 10.0.4
* @return string storage id | ||
* @since 10.0 | ||
*/ | ||
abstract public function getId(); |
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.
I don't think you should redefined this.
Please make the CacheableFlysystemAdpater extend directly from FlysystemStorageAdapter
which already provides this method.
Is this mtime caching specific to Dropbox ? https://github.com/owncloud/files_external_dropbox/blob/master/lib/Storage/Dropbox.php#L71 Isn't this information already available in this cache ? If not, does it make sense to bring this into your cacheable adapter as well or is it very specific to Dropbox ? |
Shouldn't you cache the results you got here https://github.com/owncloud/files_external_dropbox/blob/master/lib/Storage/Dropbox.php#L144 into the local cache as well ? |
Seems |
|
||
default: | ||
unset($this->cacheContents[$this->getCacheLocation($path)]); | ||
return parent::fopen($path, $mode); |
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.
it should be possible to invalidate the cache after an upload, see how it's done here: https://github.com/owncloud/core/blob/master/lib/private/Files/Storage/DAV.php#L405 and https://github.com/owncloud/core/blob/master/lib/private/Files/Storage/DAV.php#L503
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.
it should be possible to invalidate the cache after an upload, see how it's done here: https://github.com/owncloud/core/blob/master/lib/private/Files/Storage/DAV.php#L405
But then I'll have to modify the original Flysystem.php which does not have any concept of cache
OR
i'll have to duplicate the fopen function here and then add cache clear line after upload
I added it before to prevent copy/paste of duplicate code and even if file upload failed the cache is only set for a single request so I did not think it would be an issue
Yes it is specific to dropbox because in API v2 we don't get the modified time of folders so what I did was find the modified time of the files in the folder and get the largest of those values and this info is not available in cache |
Uhh I am only fetching this info if not found in cache here https://github.com/owncloud/files_external_dropbox/blob/master/lib/Storage/Dropbox.php#L139 because the cache is only for a single request cycle i think this should work |
Yes it is unused in Where you asked
|
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.
👍 fine for now, will need further optimizations in the future by adding the cache stuff in more code paths (fopen, etc)
@Hemant-Mann can you rebase ? Then do another PR to backport to stable10. |
Okay I'll do that |
Stable 10 PR #29414
Yes we can definitely add cache stuff at more places like fopen |
@Hemant-Mann thanks for the backport, can you also rebase this PR to kick CI ? |
Note: this PR is coming from a forked repo, so the Travis-Saucelabs UI tests will fail due to Saucelabs authentication issues. |
@PVince81 Can you explain a little bit as to why I have to rebase it? Is it related to @phil-davis issue
|
I see it also did not trigger the drone CI. There were some times recently when drone was down, so the job did not trigger. So rebasing will make the drone CI run. |
I rebased the branch with master but while pushing it rejected the commits and then I had to do a git pull which resulted in a merge commit
So should I push this rebased branch? |
You can locally do an interactive rebase:
and squash the commits together in whatever way seems logical (squashing out the merge commit...)
that will replace whatever is here in the PR branch with whatever you have done locally. |
fb6e397
to
3f57003
Compare
Thanks I was just missing the |
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
I have added a new cacheable flysystem adapter in owncloud so that we can connect flysystem adapters and owncloud storage
Related Issue
None
Motivation and Context
This change is required because current flysystem implementation does not utilize caching and according to owncloud documentation this should be a must feature
How Has This Been Tested?
This has been tested with the new Dropbox App in which instead of extending the storage
OCP\Files\Storage\FlysystemStorageAdapter
I now extend it withOCP\Files\Storage\CacheableFlysystemAdapter
Screenshots (if appropriate):
Types of changes
Checklist: