Skip to content

Commit 034a310

Browse files
committed
Use checksum more broadly, not specifically SHA256
1 parent 4cd44d2 commit 034a310

File tree

8 files changed

+50
-9
lines changed

8 files changed

+50
-9
lines changed

app/Models/Backup.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* @property string $name
1313
* @property string[] $ignored_files
1414
* @property string $disk
15-
* @property string|null $sha256_hash
15+
* @property string|null $checksum
1616
* @property int $bytes
1717
* @property \Carbon\CarbonImmutable|null $completed_at
1818
* @property \Carbon\CarbonImmutable $created_at
@@ -62,7 +62,7 @@ class Backup extends Model
6262
*/
6363
protected $attributes = [
6464
'is_successful' => true,
65-
'sha256_hash' => null,
65+
'checksum' => null,
6666
'bytes' => 0,
6767
];
6868

@@ -76,7 +76,7 @@ class Backup extends Model
7676
'name' => 'required|string',
7777
'ignored_files' => 'array',
7878
'disk' => 'required|string',
79-
'sha256_hash' => 'nullable|string',
79+
'checksum' => 'nullable|string',
8080
'bytes' => 'numeric',
8181
];
8282

app/Transformers/Api/Client/BackupTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function transform(Backup $backup)
2525
'is_successful' => $backup->is_successful,
2626
'name' => $backup->name,
2727
'ignored_files' => $backup->ignored_files,
28-
'sha256_hash' => $backup->sha256_hash,
28+
'checksum' => $backup->checksum,
2929
'bytes' => $backup->bytes,
3030
'created_at' => $backup->created_at->toIso8601String(),
3131
'completed_at' => $backup->completed_at ? $backup->completed_at->toIso8601String() : null,
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\DB;
4+
use Illuminate\Database\Migrations\Migration;
5+
use Illuminate\Database\Schema\Blueprint;
6+
use Illuminate\Support\Facades\Schema;
7+
8+
class ModifyChecksumsColumnForBackups extends Migration
9+
{
10+
/**
11+
* Run the migrations.
12+
*
13+
* @return void
14+
*/
15+
public function up()
16+
{
17+
Schema::table('backups', function (Blueprint $table) {
18+
$table->renameColumn('sha256_hash', 'checksum');
19+
});
20+
21+
Schema::table('backups', function (Blueprint $table) {
22+
DB::update('UPDATE backups SET checksum = CONCAT(\'sha256:\', checksum)');
23+
});
24+
}
25+
26+
/**
27+
* Reverse the migrations.
28+
*
29+
* @return void
30+
*/
31+
public function down()
32+
{
33+
Schema::table('backups', function (Blueprint $table) {
34+
$table->renameColumn('checksum', 'sha256_hash');
35+
});
36+
37+
Schema::table('backups', function (Blueprint $table) {
38+
DB::update('UPDATE backups SET sha256_hash = SUBSTRING(sha256_hash, 8)');
39+
});
40+
}
41+
}

resources/scripts/api/server/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export interface ServerBackup {
33
isSuccessful: boolean;
44
name: string;
55
ignoredFiles: string;
6-
sha256Hash: string;
6+
checksum: string;
77
bytes: number;
88
createdAt: Date;
99
completedAt: Date | null;

resources/scripts/api/transformers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const rawDataToServerBackup = ({ attributes }: FractalResponseData): Serv
4646
isSuccessful: attributes.is_successful,
4747
name: attributes.name,
4848
ignoredFiles: attributes.ignored_files,
49-
sha256Hash: attributes.sha256_hash,
49+
checksum: attributes.checksum,
5050
bytes: attributes.bytes,
5151
createdAt: new Date(attributes.created_at),
5252
completedAt: attributes.completed_at ? new Date(attributes.completed_at) : null,

resources/scripts/components/server/backups/BackupContextMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default ({ backup }: Props) => {
6666
appear
6767
visible={visible}
6868
onDismissed={() => setVisible(false)}
69-
checksum={backup.sha256Hash}
69+
checksum={backup.checksum}
7070
/>
7171
}
7272
<ConfirmationModal

resources/scripts/components/server/backups/BackupRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default ({ backup, className }: Props) => {
2929
items: data.items.map(b => b.uuid !== backup.uuid ? b : ({
3030
...b,
3131
isSuccessful: parsed.is_successful || true,
32-
sha256Hash: parsed.sha256_hash || '',
32+
checksum: parsed.checksum || '',
3333
bytes: parsed.file_size || 0,
3434
completedAt: new Date(),
3535
})),

resources/scripts/components/server/backups/ChecksumModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const ChecksumModal = ({ checksum, ...props }: RequiredModalProps & { checksum:
66
<Modal {...props}>
77
<h3 css={tw`mb-6`}>Verify file checksum</h3>
88
<p css={tw`text-sm`}>
9-
The SHA256 checksum of this file is:
9+
The checksum of this file is:
1010
</p>
1111
<pre css={tw`mt-2 text-sm p-2 bg-neutral-900 rounded`}>
1212
<code css={tw`block font-mono`}>{checksum}</code>

0 commit comments

Comments
 (0)