Call getFullPath only if its defined in storage#29337
Conversation
|
@PVince81 Let me know if you have suggestions to improve this change. |
Codecov Report
@@ Coverage Diff @@
## master #29337 +/- ##
============================================
+ Coverage 60.21% 60.21% +<.01%
- Complexity 17183 17184 +1
============================================
Files 1030 1030
Lines 57280 57281 +1
============================================
+ Hits 34493 34494 +1
Misses 22787 22787
Continue to review full report at Codecov.
|
|
This is just a quick workaround as it adds the method only on one implementation instead of the interface. I'm not sure if we should add this on the interface as it would affect every possible storage implementation out there. @sharidas please also add a PHP "has_method" (or "is_method"?) check in the encryption code to check if the target storage does have the method before calling. If not, find a way to fallback. |
426a3b4 to
8a0ee8d
Compare
|
@PVince81 Hope the new change looks better. |
| if (method_exists($sourceStorage, "getFullPath")) { | ||
| $this->sourcePath[$targetInternalPath] = $sourceStorage->getFullPath($sourceInternalPath); | ||
| } else { | ||
| $this->sourcePath[$targetInternalPath] = $mountPoint . '/' . $sourceInternalPath; |
There was a problem hiding this comment.
can $mountPoint be undefined or is it always set ?
There was a problem hiding this comment.
With OC instance with encryption enabled:
- External Storage
a) SFTP
Delete a file from SFTP. mountPoint is not empty.
Restore the file from trashbin. mountPoint is not empty
b) ownCloud
Delete a file from another oC instance ( encryption enabled ). mountPoint is not empty
There was a problem hiding this comment.
With the tests done other than fed share, I found that if condition is not getting true. The reason I guess is wrapper could be checksum and which doesn't have "getFullPath", so it moves to else.
e0f3acd to
cd39315
Compare
Call getFullPath only if its defined in storage. Else use mount point to resolve the full path. Signed-off-by: Sujith H <sharidasan@owncloud.com>
cd39315 to
6748fba
Compare
| $source = $sourceStorage->fopen($sourceInternalPath, 'r'); | ||
| if ($isRename) { | ||
| $this->sourcePath[$targetInternalPath] = $sourceStorage->getFullPath($sourceInternalPath); | ||
| if ($isRename && (count($mount) === 1)) { |
There was a problem hiding this comment.
This way $mount is not used without defining. The path obtained using this method and getFullPath in the scenario of transfer file onwership between users ( with masterkey encryption ), both path remains same.
|
Backport PR : #29360 |
|
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. |
Call getFullPath only if its defined in storage.
Else use mount point to resolve the full path.
Signed-off-by: Sujith H sharidasan@owncloud.com
Description
This change adds getFullPath method to shared external storage file.
Related Issue
#29167
Motivation and Context
Setup to recreate the issue:
testuser1using federated shareuser1in oC1 and create a file undertestSince oC1 is non encrypted and when file under
testis being deleted, the https://github.com/owncloud/core/blob/v10.0.3/lib/private/Files/Storage/Wrapper/Encryption.php#L786 code is hit. The reason is its a cross storage move. And getFullPath is defined only in Encryption storage. Its not available in other storages. So during the iteration to find the getFullPath method under storage wrappers, it couldn't find and throws the error. This change helps us to resolve that issue.How Has This Been Tested?
Recreated the issue with the steps mentioned above. After applying this change when the file is deleted, the log file doesn't spit the error message.
Screenshots (if appropriate):
Types of changes
Checklist: