Skip to content

Commit 933986d

Browse files
Fix storage unit comparison in PruneUploads job (#2819)
When we converted the culling of old uploaded files to a scheduled job in #2749 we accidentally started comparison bytes against gigabytes, resulting in this pruning step getting skipped when it shouldn't be.
1 parent 6981fb0 commit 933986d

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

app/Jobs/PruneUploads.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function handle(): void
4646
WHERE project.id = ?
4747
', [$project->id])[0]->s ?? -1);
4848

49-
if ($total_size / (1024 * 1024 * 1024) > $project->uploadquota) {
49+
if ($total_size > $project->uploadquota) {
5050
// We're over the limit, so delete references to files from oldest to newest until we're
5151
// under the limit. We're probably not over the limit by very much, so we load in relatively
5252
// small chunks to minimize the amount of data being loaded.
@@ -58,7 +58,7 @@ public function handle(): void
5858
$uploaded_files_to_check = $uploaded_files_to_check->merge($build->uploadedFiles()->pluck('id'));
5959
$build->uploadedFiles()->detach();
6060

61-
if ($total_size / (1024 * 1024 * 1024) <= $project->uploadquota) {
61+
if ($total_size <= $project->uploadquota) {
6262
// Stop the build chunking.
6363
return false;
6464
}

app/Models/Project.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* @property int $displaylabels
4242
* @property int $autoremovetimeframe
4343
* @property int $autoremovemaxbuilds
44-
* @property int $uploadquota Maximum sum of uploaded file sizes in GiB
44+
* @property int $uploadquota Maximum sum of uploaded file sizes (in bytes)
4545
* @property int $showcoveragecode
4646
* @property int $sharelabelfilters
4747
* @property int $authenticatesubmissions

tests/Feature/Jobs/PruneUploadsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function testProjectNoUploadedFiles(): void
5656

5757
public function testUploadedFilesBelowLimit(): void
5858
{
59-
$this->project->uploadquota = 2;
59+
$this->project->uploadquota = 2147483648;
6060
$this->project->save();
6161

6262
$hash = sha1_file(__FILE__);
@@ -94,7 +94,7 @@ public function testUploadedFilesBelowLimit(): void
9494

9595
public function testUploadedFilesAboveLimit(): void
9696
{
97-
$this->project->uploadquota = 1;
97+
$this->project->uploadquota = 1073741824;
9898
$this->project->save();
9999

100100
$hash = sha1_file(__FILE__);

0 commit comments

Comments
 (0)