Skip to content

Commit

Permalink
Provide relative paths to Storage::delete() (#2673)
Browse files Browse the repository at this point in the history
After a recent upgrade of CDash instances, we noticed that stale files
in the parsed/ directory were no longer getting cleaned up.
  • Loading branch information
zackgalbreath authored Jan 27, 2025
1 parent 88c87dc commit 0c5b5bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
9 changes: 4 additions & 5 deletions app/cdash/include/dailyupdates.php
Original file line number Diff line number Diff line change
Expand Up @@ -1108,14 +1108,13 @@ function addDailyChanges(int $projectid): void
', [$projectid, $date]);

// Clean the backup directories.
$timeframe = config('cdash.backup_timeframe');
$deletion_time_threshold = time() - (int) config('cdash.backup_timeframe') * 3600;
$dirs_to_clean = ['parsed', 'failed', 'inprogress'];
foreach ($dirs_to_clean as $dir_to_clean) {
$files = Storage::allFiles($dir_to_clean);
foreach ($files as $filename) {
$filepath = Storage::path($filename);
if (file_exists($filepath) && is_file($filepath) && time() - filemtime($filepath) > $timeframe * 3600) {
Storage::delete($filepath);
foreach ($files as $file) {
if (Storage::lastModified($file) < $deletion_time_threshold) {
Storage::delete($file);
}
}
}
Expand Down
15 changes: 5 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -14012,11 +14012,6 @@ parameters:
count: 3
path: app/cdash/include/dailyupdates.php

-
message: "#^Binary operation \"\\*\" between mixed and 3600 results in an error\\.$#"
count: 1
path: app/cdash/include/dailyupdates.php

-
message: """
#^Call to deprecated function add_last_sql_error\\(\\)\\:
Expand Down Expand Up @@ -14092,6 +14087,11 @@ parameters:
count: 1
path: app/cdash/include/dailyupdates.php

-
message: "#^Cannot cast mixed to int\\.$#"
count: 1
path: app/cdash/include/dailyupdates.php

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 5
Expand Down Expand Up @@ -14312,11 +14312,6 @@ parameters:
count: 2
path: app/cdash/include/dailyupdates.php

-
message: "#^Only numeric types are allowed in \\-, int\\|false given on the right side\\.$#"
count: 1
path: app/cdash/include/dailyupdates.php

-
message: "#^Parameter \\#1 \\$datetime of function strtotime expects string, string\\|null given\\.$#"
count: 1
Expand Down

0 comments on commit 0c5b5bb

Please sign in to comment.