backend: support is_successful state for backups rather than deleting it when failing

This allows the UI to correctly show failed backups to the user and require them to manually delete those backups, rather than them mysteriously disappearing.

We can also hook into this later to send a notification to the user when the backup fails.
This commit is contained in:
Dane Everitt 2020-08-20 21:07:53 -07:00
parent 6066fa40f4
commit e3178ba6f0
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
7 changed files with 58 additions and 25 deletions

View file

@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property int $id
* @property int $server_id
* @property int $uuid
* @property bool $is_successful
* @property string $name
* @property string[] $ignored_files
* @property string $disk
@ -44,6 +45,7 @@ class Backup extends Model
*/
protected $casts = [
'id' => 'int',
'is_successful' => 'bool',
'bytes' => 'int',
'ignored_files' => 'array',
];
@ -59,6 +61,7 @@ class Backup extends Model
* @var array
*/
protected $attributes = [
'is_successful' => true,
'sha256_hash' => null,
'bytes' => 0,
];
@ -69,6 +72,7 @@ class Backup extends Model
public static $validationRules = [
'server_id' => 'bail|required|numeric|exists:servers,id',
'uuid' => 'required|uuid',
'is_successful' => 'boolean',
'name' => 'required|string',
'ignored_files' => 'array',
'disk' => 'required|string',