Skip to content

Commit 9abdfdb

Browse files
committed
Provide relative paths to Storage::delete()
After a recent upgrade of CDash instances, we noticed that stale files in the parsed/ directory were no longer getting cleaned up.
1 parent 5cb23a0 commit 9abdfdb

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

app/cdash/include/dailyupdates.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,14 +1108,13 @@ function addDailyChanges(int $projectid): void
11081108
', [$projectid, $date]);
11091109

11101110
// Clean the backup directories.
1111-
$timeframe = config('cdash.backup_timeframe');
1111+
$deletion_time_threshold = time() - (int) config('cdash.backup_timeframe') * 3600;
11121112
$dirs_to_clean = ['parsed', 'failed', 'inprogress'];
11131113
foreach ($dirs_to_clean as $dir_to_clean) {
11141114
$files = Storage::allFiles($dir_to_clean);
1115-
foreach ($files as $filename) {
1116-
$filepath = Storage::path($filename);
1117-
if (file_exists($filepath) && is_file($filepath) && time() - filemtime($filepath) > $timeframe * 3600) {
1118-
Storage::delete($filepath);
1115+
foreach ($files as $file) {
1116+
if (Storage::lastModified($file) < $deletion_time_threshold) {
1117+
Storage::delete($file);
11191118
}
11201119
}
11211120
}

phpstan-baseline.neon

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14027,11 +14027,6 @@ parameters:
1402714027
count: 3
1402814028
path: app/cdash/include/dailyupdates.php
1402914029

14030-
-
14031-
message: "#^Binary operation \"\\*\" between mixed and 3600 results in an error\\.$#"
14032-
count: 1
14033-
path: app/cdash/include/dailyupdates.php
14034-
1403514030
-
1403614031
message: """
1403714032
#^Call to deprecated function add_last_sql_error\\(\\)\\:
@@ -14107,6 +14102,11 @@ parameters:
1410714102
count: 1
1410814103
path: app/cdash/include/dailyupdates.php
1410914104

14105+
-
14106+
message: "#^Cannot cast mixed to int\\.$#"
14107+
count: 1
14108+
path: app/cdash/include/dailyupdates.php
14109+
1411014110
-
1411114111
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
1411214112
count: 5
@@ -14327,11 +14327,6 @@ parameters:
1432714327
count: 2
1432814328
path: app/cdash/include/dailyupdates.php
1432914329

14330-
-
14331-
message: "#^Only numeric types are allowed in \\-, int\\|false given on the right side\\.$#"
14332-
count: 1
14333-
path: app/cdash/include/dailyupdates.php
14334-
1433514330
-
1433614331
message: "#^Parameter \\#1 \\$datetime of function strtotime expects string, string\\|null given\\.$#"
1433714332
count: 1

0 commit comments

Comments
 (0)