fix: file storages (dir/file mount) handled properly

This commit is contained in:
Andras Bacsai
2024-08-05 20:00:57 +02:00
parent 8133a8b770
commit ea5101c814
10 changed files with 118 additions and 34 deletions

View File

@@ -26,6 +26,8 @@ class FileStorage extends Component
public ?string $workdir = null;
public bool $permanently_delete = true;
protected $rules = [
'fileStorage.is_directory' => 'required',
'fileStorage.fs_path' => 'required',
@@ -56,7 +58,7 @@ class FileStorage extends Component
} catch (\Throwable $e) {
return handleError($e, $this);
} finally {
$this->dispatch('refresh_storages');
$this->dispatch('refreshStorages');
}
}
@@ -71,20 +73,27 @@ class FileStorage extends Component
} catch (\Throwable $e) {
return handleError($e, $this);
} finally {
$this->dispatch('refresh_storages');
$this->dispatch('refreshStorages');
}
}
public function delete()
{
try {
$this->fileStorage->deleteStorageOnServer();
$message = 'File deleted.';
if ($this->fileStorage->is_directory) {
$message = 'Directory deleted.';
}
if ($this->permanently_delete) {
$message = 'Directory deleted from the server.';
$this->fileStorage->deleteStorageOnServer();
}
$this->fileStorage->delete();
$this->dispatch('success', 'File deleted.');
$this->dispatch('success', $message);
} catch (\Throwable $e) {
return handleError($e, $this);
} finally {
$this->dispatch('refresh_storages');
$this->dispatch('refreshStorages');
}
}