fix: Correctly create NonExistingFolder during copy

Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
Louis Chemineau 2024-11-19 13:04:47 +01:00
parent be7b6a7b1b
commit 9ff3ba7ce0
No known key found for this signature in database
2 changed files with 5 additions and 4 deletions

View file

@ -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();

View file

@ -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);