Flex FolderStorage: Added support for partial delete

This commit is contained in:
Matias Griese
2019-09-05 17:20:08 +03:00
parent 603bb6c878
commit beb8f09a9d

View File

@@ -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.
*