Skip to content

Commit 32d4808

Browse files
authored
Ignore stray files, but log a notice when they are discovered during garbage collection (#8198)
1 parent 9071b4c commit 32d4808

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

app/lib/package/api_export/exported_api.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import 'package:crypto/crypto.dart';
1313
import 'package:gcloud/storage.dart';
1414
import 'package:logging/logging.dart';
1515
import 'package:pool/pool.dart';
16+
import 'package:pub_dev/shared/monitoring.dart';
1617
import 'package:pub_dev/shared/utils.dart';
1718
import '../../shared/storage.dart';
1819
import '../../shared/versions.dart'
@@ -138,6 +139,10 @@ final class ExportedApi {
138139
);
139140
await Future.wait(topLevelprefixes.map((entry) async {
140141
if (entry.isObject) {
142+
_log.pubNoticeShout(
143+
'stray-file',
144+
'Found stray top-level file "${entry.name}" in ExportedApi',
145+
);
141146
return; // ignore top-level files
142147
}
143148

@@ -147,6 +152,10 @@ final class ExportedApi {
147152
}
148153

149154
if (!runtimeVersionPattern.hasMatch(topLevelPrefix)) {
155+
_log.pubNoticeShout(
156+
'stray-file',
157+
'Found stray top-level prefix "${entry.name}" in ExportedApi',
158+
);
150159
return; // Don't GC non-runtimeVersions
151160
}
152161

@@ -227,6 +236,14 @@ final class ExportedPackage {
227236
final pfx = '/api/archives/$_package-';
228237
await _owner._listBucket(prefix: pfx, delimiter: '', (item) async {
229238
assert(item.isObject);
239+
if (!item.name.endsWith('.tar.gz')) {
240+
_log.pubNoticeShout(
241+
'stray-file',
242+
'Found stray file "${item.name}" in ExportedApi'
243+
' while garbage collecting for "$_package" (ignoring it!)',
244+
);
245+
return;
246+
}
230247
final version = item.name.without(prefix: pfx, suffix: '.tar.gz');
231248
if (allVersionNumbers.contains(version)) {
232249
return;

0 commit comments

Comments
 (0)