feat: listen to user life cycle events
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -268,6 +268,34 @@ class BlobStore {
|
||||
return $blobDeleted && $metaDeleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanently remove the configured user storage root.
|
||||
*/
|
||||
public function rootDestroy(): void {
|
||||
if ($this->rootPath === null || !is_dir($this->rootPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$root = realpath($this->rootPath);
|
||||
if ($root === false || $root === DIRECTORY_SEPARATOR) {
|
||||
throw new RuntimeException('Refusing to destroy an invalid blob root');
|
||||
}
|
||||
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \RecursiveDirectoryIterator($root, \FilesystemIterator::SKIP_DOTS),
|
||||
\RecursiveIteratorIterator::CHILD_FIRST,
|
||||
);
|
||||
foreach ($iterator as $entry) {
|
||||
if ($entry->isDir() && !$entry->isLink()) {
|
||||
rmdir($entry->getPathname());
|
||||
} else {
|
||||
unlink($entry->getPathname());
|
||||
}
|
||||
}
|
||||
rmdir($root);
|
||||
$this->rootPath = null;
|
||||
}
|
||||
|
||||
// ========== Blob Existence Check ==========
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user