mirror of
https://github.com/getgrav/grav.git
synced 2026-02-21 14:08:02 +01:00
Flex FolderStorage: Added support for partial delete
This commit is contained in:
@@ -173,14 +173,16 @@ class FolderStorage extends AbstractFilesystemStorage
|
||||
$file = $this->getFile($path);
|
||||
$list[$key] = $this->deleteFile($file);
|
||||
|
||||
$storagePath = $this->getStoragePath($key);
|
||||
$mediaPath = $this->getMediaPath($key);
|
||||
if ($this->canDeleteFolder($key)) {
|
||||
$storagePath = $this->getStoragePath($key);
|
||||
$mediaPath = $this->getMediaPath($key);
|
||||
|
||||
if ($storagePath) {
|
||||
$this->deleteFolder($storagePath, true);
|
||||
}
|
||||
if ($mediaPath && $mediaPath !== $storagePath && $mediaPath !== $baseMediaPath) {
|
||||
$this->deleteFolder($mediaPath, true);
|
||||
if ($storagePath) {
|
||||
$this->deleteFolder($storagePath, true);
|
||||
}
|
||||
if ($mediaPath && $mediaPath !== $storagePath && $mediaPath !== $baseMediaPath) {
|
||||
$this->deleteFolder($mediaPath, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -462,6 +464,14 @@ class FolderStorage extends AbstractFilesystemStorage
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function canDeleteFolder(string $key): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns list of all stored keys in [key => timestamp] pairs.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user