mirror of
https://github.com/nextcloud/server.git
synced 2026-04-24 23:59:27 -04:00
Merge pull request #47847 from nextcloud/fix-copying-or-moving-from-shared-groupfolders
This commit is contained in:
commit
e3e22e28c0
2 changed files with 29 additions and 2 deletions
|
|
@ -538,11 +538,13 @@ class Local extends \OC\Files\Storage\Common {
|
|||
|
||||
public function copyFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath, bool $preserveMtime = false): bool {
|
||||
if ($this->canDoCrossStorageMove($sourceStorage)) {
|
||||
if ($sourceStorage->instanceOfStorage(Jail::class)) {
|
||||
// resolve any jailed paths
|
||||
while ($sourceStorage->instanceOfStorage(Jail::class)) {
|
||||
/**
|
||||
* @var \OC\Files\Storage\Wrapper\Jail $sourceStorage
|
||||
*/
|
||||
$sourceInternalPath = $sourceStorage->getUnjailedPath($sourceInternalPath);
|
||||
$sourceStorage = $sourceStorage->getUnjailedStorage();
|
||||
}
|
||||
/**
|
||||
* @var \OC\Files\Storage\Local $sourceStorage
|
||||
|
|
@ -556,11 +558,13 @@ class Local extends \OC\Files\Storage\Common {
|
|||
|
||||
public function moveFromStorage(IStorage $sourceStorage, string $sourceInternalPath, string $targetInternalPath): bool {
|
||||
if ($this->canDoCrossStorageMove($sourceStorage)) {
|
||||
if ($sourceStorage->instanceOfStorage(Jail::class)) {
|
||||
// resolve any jailed paths
|
||||
while ($sourceStorage->instanceOfStorage(Jail::class)) {
|
||||
/**
|
||||
* @var \OC\Files\Storage\Wrapper\Jail $sourceStorage
|
||||
*/
|
||||
$sourceInternalPath = $sourceStorage->getUnjailedPath($sourceInternalPath);
|
||||
$sourceStorage = $sourceStorage->getUnjailedStorage();
|
||||
}
|
||||
/**
|
||||
* @var \OC\Files\Storage\Local $sourceStorage
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Test\Files\Storage;
|
||||
|
||||
use OC\Files\Storage\Wrapper\Jail;
|
||||
|
||||
/**
|
||||
* Class LocalTest
|
||||
*
|
||||
|
|
@ -135,4 +137,25 @@ class LocalTest extends Storage {
|
|||
// no exception thrown
|
||||
$this->assertNotNull($this->instance);
|
||||
}
|
||||
|
||||
public function testMoveNestedJail(): void {
|
||||
$this->instance->mkdir('foo');
|
||||
$this->instance->mkdir('foo/bar');
|
||||
$this->instance->mkdir('target');
|
||||
$this->instance->file_put_contents('foo/bar/file.txt', 'foo');
|
||||
$jail1 = new Jail([
|
||||
'storage' => $this->instance,
|
||||
'root' => 'foo'
|
||||
]);
|
||||
$jail2 = new Jail([
|
||||
'storage' => $jail1,
|
||||
'root' => 'bar'
|
||||
]);
|
||||
$jail3 = new Jail([
|
||||
'storage' => $this->instance,
|
||||
'root' => 'target'
|
||||
]);
|
||||
$jail3->moveFromStorage($jail2, 'file.txt', 'file.txt');
|
||||
$this->assertTrue($this->instance->file_exists('target/file.txt'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue