mirror of
https://github.com/nextcloud/server.git
synced 2026-03-03 05:51:07 -05:00
fix: Correctly create NonExistingFolder during copy
Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
parent
be7b6a7b1b
commit
9ff3ba7ce0
2 changed files with 5 additions and 4 deletions
|
|
@ -11,6 +11,7 @@ namespace OCA\Files_Versions\Listener;
|
|||
|
||||
use Exception;
|
||||
use OC\Files\Node\NonExistingFile;
|
||||
use OC\Files\Node\NonExistingFolder;
|
||||
use OCA\Files_Versions\Versions\IVersionBackend;
|
||||
use OCA\Files_Versions\Versions\IVersionManager;
|
||||
use OCA\Files_Versions\Versions\IVersionsImporterBackend;
|
||||
|
|
@ -130,7 +131,7 @@ class VersionStorageMoveListener implements IEventListener {
|
|||
}
|
||||
|
||||
private function getNodeStorage(Node $node): IStorage {
|
||||
if ($node instanceof NonExistingFile) {
|
||||
if ($node instanceof NonExistingFile || $node instanceof NonExistingFolder) {
|
||||
return $node->getParent()->getStorage();
|
||||
} else {
|
||||
return $node->getStorage();
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ class HookConnector {
|
|||
|
||||
public function copy($arguments) {
|
||||
$source = $this->getNodeForPath($arguments['oldpath']);
|
||||
$target = $this->getNodeForPath($arguments['newpath']);
|
||||
$target = $this->getNodeForPath($arguments['newpath'], $source instanceof Folder);
|
||||
$this->root->emit('\OC\Files', 'preCopy', [$source, $target]);
|
||||
$this->dispatcher->dispatch('\OCP\Files::preCopy', new GenericEvent([$source, $target]));
|
||||
|
||||
|
|
@ -203,7 +203,7 @@ class HookConnector {
|
|||
$this->dispatcher->dispatchTyped($event);
|
||||
}
|
||||
|
||||
private function getNodeForPath(string $path): Node {
|
||||
private function getNodeForPath(string $path, bool $isDir = false): Node {
|
||||
$info = Filesystem::getView()->getFileInfo($path);
|
||||
if (!$info) {
|
||||
$fullPath = Filesystem::getView()->getAbsolutePath($path);
|
||||
|
|
@ -212,7 +212,7 @@ class HookConnector {
|
|||
} else {
|
||||
$info = null;
|
||||
}
|
||||
if (Filesystem::is_dir($path)) {
|
||||
if ($isDir || Filesystem::is_dir($path)) {
|
||||
return new NonExistingFolder($this->root, $this->view, $fullPath, $info);
|
||||
} else {
|
||||
return new NonExistingFile($this->root, $this->view, $fullPath, $info);
|
||||
|
|
|
|||
Loading…
Reference in a new issue