mirror of
https://github.com/getgrav/grav.git
synced 2025-12-05 15:29:57 +01:00
Fix slow SafeUpgradeServiceTest by optimizing snapshot pruning
This commit is contained in:
@@ -1184,7 +1184,12 @@ class SafeUpgradeService
|
||||
|
||||
// Sort by created_at descending
|
||||
usort($manifests, static function ($a, $b) {
|
||||
return $b['created_at'] <=> $a['created_at'];
|
||||
$result = $b['created_at'] <=> $a['created_at'];
|
||||
if ($result === 0) {
|
||||
return strcmp($b['path'], $a['path']);
|
||||
}
|
||||
|
||||
return $result;
|
||||
});
|
||||
|
||||
$toDelete = array_slice($manifests, $limit);
|
||||
|
||||
@@ -128,9 +128,6 @@ class SafeUpgradeServiceTest extends \Codeception\TestCase\Test
|
||||
$manifests[] = $service->promote($package, '1.8.' . $i, ['backup', 'cache', 'images', 'logs', 'tmp', 'user']);
|
||||
// Ensure subsequent promotions have a marker to restore.
|
||||
file_put_contents($root . '/ORIGINAL', 'state-' . $i);
|
||||
// Sleep to ensure different timestamps for sorting (time() has 1s resolution)
|
||||
sleep(1);
|
||||
usleep(100000); // +100ms to be sure
|
||||
}
|
||||
|
||||
$files = glob($manifestStore . '/*.json');
|
||||
|
||||
Reference in New Issue
Block a user