mirror of
https://github.com/nextcloud/server.git
synced 2026-03-11 02:41:25 -04:00
fix moving files of encrypted local storage to unencrypted local storage
for example when moving encrypted files to a groupfolder Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
dc737047ce
commit
920e8ad21a
1 changed files with 13 additions and 5 deletions
|
|
@ -43,6 +43,7 @@
|
|||
namespace OC\Files\Storage;
|
||||
|
||||
use OC\Files\Filesystem;
|
||||
use OC\Files\Storage\Wrapper\Encryption;
|
||||
use OC\Files\Storage\Wrapper\Jail;
|
||||
use OCP\Constants;
|
||||
use OCP\Files\ForbiddenException;
|
||||
|
|
@ -538,6 +539,16 @@ class Local extends \OC\Files\Storage\Common {
|
|||
}
|
||||
}
|
||||
|
||||
private function canDoCrossStorageMove(IStorage $sourceStorage) {
|
||||
return $sourceStorage->instanceOfStorage(Local::class)
|
||||
// Don't treat ACLStorageWrapper like local storage where copy can be done directly.
|
||||
// Instead, use the slower recursive copying in php from Common::copyFromStorage with
|
||||
// more permissions checks.
|
||||
&& !$sourceStorage->instanceOfStorage('OCA\GroupFolders\ACL\ACLStorageWrapper')
|
||||
// when moving encrypted files we have to handle keys and the target might not be encrypted
|
||||
&& !$sourceStorage->instanceOfStorage(Encryption::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IStorage $sourceStorage
|
||||
* @param string $sourceInternalPath
|
||||
|
|
@ -546,10 +557,7 @@ class Local extends \OC\Files\Storage\Common {
|
|||
* @return bool
|
||||
*/
|
||||
public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false) {
|
||||
// Don't treat ACLStorageWrapper like local storage where copy can be done directly.
|
||||
// Instead use the slower recursive copying in php from Common::copyFromStorage with
|
||||
// more permissions checks.
|
||||
if ($sourceStorage->instanceOfStorage(Local::class) && !$sourceStorage->instanceOfStorage('OCA\GroupFolders\ACL\ACLStorageWrapper')) {
|
||||
if ($this->canDoCrossStorageMove($sourceStorage)) {
|
||||
if ($sourceStorage->instanceOfStorage(Jail::class)) {
|
||||
/**
|
||||
* @var \OC\Files\Storage\Wrapper\Jail $sourceStorage
|
||||
|
|
@ -573,7 +581,7 @@ class Local extends \OC\Files\Storage\Common {
|
|||
* @return bool
|
||||
*/
|
||||
public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
|
||||
if ($sourceStorage->instanceOfStorage(Local::class)) {
|
||||
if ($this->canDoCrossStorageMove($sourceStorage)) {
|
||||
if ($sourceStorage->instanceOfStorage(Jail::class)) {
|
||||
/**
|
||||
* @var \OC\Files\Storage\Wrapper\Jail $sourceStorage
|
||||
|
|
|
|||
Loading…
Reference in a new issue