Skip to content

Commit 0c5b5bb

Browse files
Provide relative paths to Storage::delete() (#2673)
After a recent upgrade of CDash instances, we noticed that stale files in the parsed/ directory were no longer getting cleaned up.
1 parent 88c87dc commit 0c5b5bb

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
@@ -14012,11 +14012,6 @@ parameters:
1401214012
count: 3
1401314013
path: app/cdash/include/dailyupdates.php
1401414014

14015-
-
14016-
message: "#^Binary operation \"\\*\" between mixed and 3600 results in an error\\.$#"
14017-
count: 1
14018-
path: app/cdash/include/dailyupdates.php
14019-
1402014015
-
1402114016
message: """
1402214017
#^Call to deprecated function add_last_sql_error\\(\\)\\:
@@ -14092,6 +14087,11 @@ parameters:
1409214087
count: 1
1409314088
path: app/cdash/include/dailyupdates.php
1409414089

14090+
-
14091+
message: "#^Cannot cast mixed to int\\.$#"
14092+
count: 1
14093+
path: app/cdash/include/dailyupdates.php
14094+
1409514095
-
1409614096
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
1409714097
count: 5
@@ -14312,11 +14312,6 @@ parameters:
1431214312
count: 2
1431314313
path: app/cdash/include/dailyupdates.php
1431414314

14315-
-
14316-
message: "#^Only numeric types are allowed in \\-, int\\|false given on the right side\\.$#"
14317-
count: 1
14318-
path: app/cdash/include/dailyupdates.php
14319-
1432014315
-
1432114316
message: "#^Parameter \\#1 \\$datetime of function strtotime expects string, string\\|null given\\.$#"
1432214317
count: 1

0 commit comments

Comments
 (0)