-
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
Fix the regression caused due to usage of part file in decrypt-all #32401
Conversation
Codecov Report
@@ Coverage Diff @@
## master #32401 +/- ##
============================================
- Coverage 64.11% 63.34% -0.78%
+ Complexity 18641 18636 -5
============================================
Files 1176 1176
Lines 70185 70104 -81
Branches 1270 1267 -3
============================================
- Hits 45002 44406 -596
- Misses 24813 25328 +515
Partials 370 370
Continue to review full report at Codecov.
|
@@ -271,7 +271,9 @@ protected function decryptFile($path) { | |||
\OC\Files\Storage\Wrapper\Encryption::setDisableWriteEncryption(true); | |||
$this->rootView->copy($source, $target); | |||
\OC\Files\Storage\Wrapper\Encryption::setDisableWriteEncryption(false); | |||
\OC::$server->getConfig()->setAppValue('core', 'ignorepartfile', 'true'); |
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.
why not use a static function like above with Encryption::setDisableWriteEncryption
, considering that this disabling only needs to happen in a single call and not be shared ?
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.
So if I understood correctly, it would be better to have a static function like Encryption::setDisableWriteEncryption
. All we have to do is block this call when rename operation is performed during decrypt-all : https://github.com/owncloud/core/blob/master/lib/private/Files/View.php#L843 and execute the else part. Would it be really bad if I have a static method in View.php to ignore the part file? So that user calls the method View::ignorePartFile(true)
, and the variable holding true|false
can be used to check the same.
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.
a static method would be better than writing to the config in the DB
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.
295add3
to
370f0a6
Compare
* User can create part files example to a call for rename(), in effect | ||
* it might not be a part file. So for better control in such cases this | ||
* method would help to let the method in rename() to know if it is a | ||
* part file. |
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 see there are other locations in rename() where isPartialFile has a different logic.
Are you sure we shouldn't also exclude those ?
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 tried to debug, based on the code flow which was causing the exception. I will post my update here after debugging further whether we need to apply exclude part file logic in those places or not.
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.
After debugging around code https://github.com/owncloud/core/blob/master/lib/private/Files/View.php#L853-L869, lets say if I modify line https://github.com/owncloud/core/blob/master/lib/private/Files/View.php#L853 by having a check to ignore part file, the code flow will reach the else part. In the else part the shouldEmitHooks()
method is called. And the path1 here will be considered as a part file by that function. Which means no signal will be emitted.
Now lets say if we don't make any changes to the PR and debug the above section where ignore part file change is missing. In this case, the code flow would call shouldEmitHooks
of the if
section. Which will return false, because of missing or empty path. Which means https://github.com/owncloud/core/blob/master/lib/private/Files/View.php#L855 will not be called.
Hence in my observation the result remains same, if we add the change of ignore part in the remaining part of the rename or not.
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.
he exception was happening because .part file wasn't added to the filecache
would this change add the part file to the file cache ??
I'm still not clear why we need this hacky magic
Also, if your goal is to avoid writeUpdate
then the flag needs to be checked around that and avoid it going to else as it would trigger another update in the else block.
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.
No this change will not add the part file to the cache.
Yes, the intention here is to skip the writeUpdate
and call renameUpdate
. The else block update would not cause issue. For testing I tried to exclude the creation of .part
file and then the code flow took the renameUpdate
which didn't caused the exception. That's the reason I added the change in the if block of writeUpdate
. If the code flow takes the writeUpdate
path, that's where the whole problem for exception occurs.
It would have been too generic if I try to move this logic into the Files/Cache/Scanner.php and then check in isPartialFile
method if the file is not part file. That would cause another exception at
core/lib/private/Files/View.php
Line 796 in 370f0a6
\OC_Hook::emit( |
pre_renameOrCopy_hook()
.
Let me know if more information needs to be added, then I can explain with the code paths without this change and with the change.
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.
👍
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.
👍 ugly but I don't have any better ideas...
I agree.. sigh. |
command Fix the regression cuased due to the usage of part file in decryptall command. An exception was thrown in the log file during the rename operation. Signed-off-by: Sujith H <sharidasan@owncloud.com>
370f0a6
to
6f88726
Compare
Backport PR #32504 |
command
Fix the regression cuased due to the usage of part file in
decryptall command. An exception was thrown in the log
file during the rename operation.
Signed-off-by: Sujith H sharidasan@owncloud.com
Description
This change fixes the exception caused during rename operation in the decrypt-all. This issue was caused due to the introduction of using
.part
extension to the target. The .part file change in the decrypt-all, didn't affected the outcome of rename method. In fact the files were getting decrypted properly. The exception was happening because.part
file wasn't added to the filecache, and the during the cod flow, fileinfo of the.part
file was being accessed. Which was not there. Hence caused an exception which was logged. Basically, the exception didn't harmed the rename operation. In this change, we let the rename method know that this part file needs to be ignored.Related Issue
Motivation and Context
This change fixes the exception caused during rename operation in the decrypt-all. This issue was caused due to the introduction of using
.part
extension to the target.How Has This Been Tested?
With this PR I have tested with the shares as follows:
admin
anduser1
user1
and logout.admin
and create a groupgroup1
.user1
togroup1
localshare.txt
and share withuser1
groupshare.txt
and share withgroup1
publiclink.txt
and create public link share of the file.files_encryption
in the data folderAll the shares created were accessible for
user1
. The public link was also accessible.Did not found the data loss. The shares were again available.
Screenshots (if appropriate):
Types of changes
Checklist:
Open tasks: