Use checksum more broadly, not specifically SHA256
This commit is contained in:
parent
4cd44d2025
commit
034a310702
|
@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
* @property string $name
|
* @property string $name
|
||||||
* @property string[] $ignored_files
|
* @property string[] $ignored_files
|
||||||
* @property string $disk
|
* @property string $disk
|
||||||
* @property string|null $sha256_hash
|
* @property string|null $checksum
|
||||||
* @property int $bytes
|
* @property int $bytes
|
||||||
* @property \Carbon\CarbonImmutable|null $completed_at
|
* @property \Carbon\CarbonImmutable|null $completed_at
|
||||||
* @property \Carbon\CarbonImmutable $created_at
|
* @property \Carbon\CarbonImmutable $created_at
|
||||||
|
@ -62,7 +62,7 @@ class Backup extends Model
|
||||||
*/
|
*/
|
||||||
protected $attributes = [
|
protected $attributes = [
|
||||||
'is_successful' => true,
|
'is_successful' => true,
|
||||||
'sha256_hash' => null,
|
'checksum' => null,
|
||||||
'bytes' => 0,
|
'bytes' => 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class Backup extends Model
|
||||||
'name' => 'required|string',
|
'name' => 'required|string',
|
||||||
'ignored_files' => 'array',
|
'ignored_files' => 'array',
|
||||||
'disk' => 'required|string',
|
'disk' => 'required|string',
|
||||||
'sha256_hash' => 'nullable|string',
|
'checksum' => 'nullable|string',
|
||||||
'bytes' => 'numeric',
|
'bytes' => 'numeric',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ class BackupTransformer extends BaseClientTransformer
|
||||||
'is_successful' => $backup->is_successful,
|
'is_successful' => $backup->is_successful,
|
||||||
'name' => $backup->name,
|
'name' => $backup->name,
|
||||||
'ignored_files' => $backup->ignored_files,
|
'ignored_files' => $backup->ignored_files,
|
||||||
'sha256_hash' => $backup->sha256_hash,
|
'checksum' => $backup->checksum,
|
||||||
'bytes' => $backup->bytes,
|
'bytes' => $backup->bytes,
|
||||||
'created_at' => $backup->created_at->toIso8601String(),
|
'created_at' => $backup->created_at->toIso8601String(),
|
||||||
'completed_at' => $backup->completed_at ? $backup->completed_at->toIso8601String() : null,
|
'completed_at' => $backup->completed_at ? $backup->completed_at->toIso8601String() : null,
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class ModifyChecksumsColumnForBackups extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('backups', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('sha256_hash', 'checksum');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('backups', function (Blueprint $table) {
|
||||||
|
DB::update('UPDATE backups SET checksum = CONCAT(\'sha256:\', checksum)');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('backups', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('checksum', 'sha256_hash');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('backups', function (Blueprint $table) {
|
||||||
|
DB::update('UPDATE backups SET sha256_hash = SUBSTRING(sha256_hash, 8)');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,7 +3,7 @@ export interface ServerBackup {
|
||||||
isSuccessful: boolean;
|
isSuccessful: boolean;
|
||||||
name: string;
|
name: string;
|
||||||
ignoredFiles: string;
|
ignoredFiles: string;
|
||||||
sha256Hash: string;
|
checksum: string;
|
||||||
bytes: number;
|
bytes: number;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
completedAt: Date | null;
|
completedAt: Date | null;
|
||||||
|
|
|
@ -46,7 +46,7 @@ export const rawDataToServerBackup = ({ attributes }: FractalResponseData): Serv
|
||||||
isSuccessful: attributes.is_successful,
|
isSuccessful: attributes.is_successful,
|
||||||
name: attributes.name,
|
name: attributes.name,
|
||||||
ignoredFiles: attributes.ignored_files,
|
ignoredFiles: attributes.ignored_files,
|
||||||
sha256Hash: attributes.sha256_hash,
|
checksum: attributes.checksum,
|
||||||
bytes: attributes.bytes,
|
bytes: attributes.bytes,
|
||||||
createdAt: new Date(attributes.created_at),
|
createdAt: new Date(attributes.created_at),
|
||||||
completedAt: attributes.completed_at ? new Date(attributes.completed_at) : null,
|
completedAt: attributes.completed_at ? new Date(attributes.completed_at) : null,
|
||||||
|
|
|
@ -66,7 +66,7 @@ export default ({ backup }: Props) => {
|
||||||
appear
|
appear
|
||||||
visible={visible}
|
visible={visible}
|
||||||
onDismissed={() => setVisible(false)}
|
onDismissed={() => setVisible(false)}
|
||||||
checksum={backup.sha256Hash}
|
checksum={backup.checksum}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
<ConfirmationModal
|
<ConfirmationModal
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default ({ backup, className }: Props) => {
|
||||||
items: data.items.map(b => b.uuid !== backup.uuid ? b : ({
|
items: data.items.map(b => b.uuid !== backup.uuid ? b : ({
|
||||||
...b,
|
...b,
|
||||||
isSuccessful: parsed.is_successful || true,
|
isSuccessful: parsed.is_successful || true,
|
||||||
sha256Hash: parsed.sha256_hash || '',
|
checksum: parsed.checksum || '',
|
||||||
bytes: parsed.file_size || 0,
|
bytes: parsed.file_size || 0,
|
||||||
completedAt: new Date(),
|
completedAt: new Date(),
|
||||||
})),
|
})),
|
||||||
|
|
|
@ -6,7 +6,7 @@ const ChecksumModal = ({ checksum, ...props }: RequiredModalProps & { checksum:
|
||||||
<Modal {...props}>
|
<Modal {...props}>
|
||||||
<h3 css={tw`mb-6`}>Verify file checksum</h3>
|
<h3 css={tw`mb-6`}>Verify file checksum</h3>
|
||||||
<p css={tw`text-sm`}>
|
<p css={tw`text-sm`}>
|
||||||
The SHA256 checksum of this file is:
|
The checksum of this file is:
|
||||||
</p>
|
</p>
|
||||||
<pre css={tw`mt-2 text-sm p-2 bg-neutral-900 rounded`}>
|
<pre css={tw`mt-2 text-sm p-2 bg-neutral-900 rounded`}>
|
||||||
<code css={tw`block font-mono`}>{checksum}</code>
|
<code css={tw`block font-mono`}>{checksum}</code>
|
||||||
|
|
Loading…
Reference in New Issue