Skip to content

Commit 1874947

Browse files
committed
ignore-timestamp -> collect-recent
1 parent c311842 commit 1874947

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/src/command/cache_gc.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CacheGcCommand extends PubCommand {
3232
hideNegatedUsage: true,
3333
);
3434
argParser.addFlag(
35-
'ignore-timestamp',
35+
'collect-recent',
3636
help: 'Also delete recent files',
3737
hideNegatedUsage: true,
3838
);
@@ -47,7 +47,11 @@ class CacheGcCommand extends PubCommand {
4747
Future<void> runProtected() async {
4848
final dryRun = argResults.flag('dry-run');
4949
final activeRoots = cache.activeRoots();
50+
// All the `activeRoots` that we could read and parse a
51+
// .dart_tool/packageConfig.json from.
5052
final validActiveRoots = <String>[];
53+
// All the rootUri paths to cached packages included from
54+
// `validActiveRoots`.
5155
final paths = <String>{};
5256
for (final packageConfigPath in activeRoots) {
5357
late final PackageConfig packageConfig;
@@ -97,7 +101,7 @@ class CacheGcCommand extends PubCommand {
97101
// conditions with ongoing `pub get` processes.
98102
final s = statPath(path);
99103
if (s.type == FileSystemEntityType.notFound) return false;
100-
if (argResults.flag('ignore-timestamp')) return true;
104+
if (argResults.flag('collect-recent')) return true;
101105
return now.difference(s.modified) > dontRemoveFilesOlderThan;
102106
}).toList();
103107
if (validActiveRoots.isEmpty) {

test/cache/gc_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void main() async {
9393

9494
test('gcing an empty cache behaves well', () async {
9595
await runPub(
96-
args: ['cache', 'gc', '--force', '--ignore-timestamp'],
96+
args: ['cache', 'gc', '--force', '--collect-recent'],
9797
output: allOf(
9898
contains('Found no active projects.'),
9999
contains('No unused cache entries found.'),
@@ -154,7 +154,7 @@ void main() async {
154154
);
155155
final s = RegExp.escape(p.separator);
156156
await runPub(
157-
args: ['cache', 'gc', '--force', '--ignore-timestamp', '--dry-run'],
157+
args: ['cache', 'gc', '--force', '--collect-recent', '--dry-run'],
158158
output: allOf([
159159
matchesAppPath,
160160
contains(RegExp('Would recover [0-9]{3} KB.')),
@@ -170,7 +170,7 @@ void main() async {
170170
]),
171171
);
172172
await runPub(
173-
args: ['cache', 'gc', '--force', '--ignore-timestamp'],
173+
args: ['cache', 'gc', '--force', '--collect-recent'],
174174
output: allOf(
175175
matchesAppPath,
176176
contains(RegExp('Will recover [0-9]{3} KB.')),

0 commit comments

Comments
 (0)