mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix: Flag folder objects that got deleted to recreate them if needed
AppData caches folder objects, and several places get them to delete them, so afterwards if the folder gets reused in the same session an error happens. This is the case in unit tests with user avatars. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
2c0f22ea4c
commit
9277a17a3c
1 changed files with 11 additions and 0 deletions
|
|
@ -31,6 +31,8 @@ class Folder extends Node implements \OCP\Files\Folder {
|
|||
|
||||
private ?IUserManager $userManager = null;
|
||||
|
||||
private bool $wasDeleted = false;
|
||||
|
||||
/**
|
||||
* Creates a Folder that represents a non-existing path
|
||||
*
|
||||
|
|
@ -162,6 +164,7 @@ class Folder extends Node implements \OCP\Files\Folder {
|
|||
if ($path === '') {
|
||||
throw new NotPermittedException('Could not create as provided path is empty');
|
||||
}
|
||||
$this->recreateIfNeeded();
|
||||
if ($this->checkPermissions(\OCP\Constants::PERMISSION_CREATE)) {
|
||||
$fullPath = $this->getFullPath($path);
|
||||
$nonExisting = new NonExistingFile($this->root, $this->view, $fullPath);
|
||||
|
|
@ -377,6 +380,7 @@ class Folder extends Node implements \OCP\Files\Folder {
|
|||
$this->view->rmdir($this->path);
|
||||
$nonExisting = new NonExistingFolder($this->root, $this->view, $this->path, $fileInfo);
|
||||
$this->sendHooks(['postDelete'], [$nonExisting]);
|
||||
$this->wasDeleted = true;
|
||||
} else {
|
||||
throw new NotPermittedException('No delete permission for path "' . $this->path . '"');
|
||||
}
|
||||
|
|
@ -469,4 +473,11 @@ class Folder extends Node implements \OCP\Files\Folder {
|
|||
$readonly,
|
||||
);
|
||||
}
|
||||
|
||||
private function recreateIfNeeded(): void {
|
||||
if ($this->wasDeleted) {
|
||||
$this->newFolder('');
|
||||
$this->wasDeleted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue