Skip to content

Commit 42b800a

Browse files
authored
Updated integrity and cache handling. (#8926)
1 parent 6c5d19e commit 42b800a

File tree

3 files changed

+8
-27
lines changed

3 files changed

+8
-27
lines changed

app/lib/package/backend.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,11 +1750,6 @@ class PackageBackend {
17501750
await tarballStorage.deleteArchiveFromAllBuckets(package, version);
17511751
}
17521752

1753-
/// Gets the file info of a [package] in the given [version].
1754-
Future<ObjectInfo?> packageTarballInfo(String package, String version) async {
1755-
return await tarballStorage.getPublicBucketArchiveInfo(package, version);
1756-
}
1757-
17581753
void _updatePackageAutomatedPublishingLock(
17591754
Package package, AuthenticatedAgent agent) {
17601755
final current = package.automatedPublishing;

app/lib/shared/integrity.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,8 +1059,8 @@ class TarballIntegrityChecker extends _BaseIntegrityChecker {
10591059
pv.package, pv.version!,
10601060
baseUri: activeConfiguration.primaryApiUri));
10611061

1062-
final shouldBeInPublicBucket =
1063-
await packageBackend.isPackageVisible(pv.package) && pv.isVisible;
1062+
final isPackageVisible = await packageBackend.isPackageVisible(pv.package);
1063+
final shouldBeInPublicBucket = isPackageVisible && pv.isVisible;
10641064

10651065
final canonicalInfo = await packageBackend.tarballStorage
10661066
.getCanonicalBucketArchiveInfo(pv.package, pv.version!);
@@ -1069,11 +1069,12 @@ class TarballIntegrityChecker extends _BaseIntegrityChecker {
10691069
return;
10701070
}
10711071

1072-
final info =
1073-
await packageBackend.packageTarballInfo(pv.package, pv.version!);
1072+
final info = await packageBackend.tarballStorage
1073+
.getPublicBucketArchiveInfo(pv.package, pv.version!);
10741074
if (info == null) {
10751075
if (shouldBeInPublicBucket) {
1076-
yield 'PackageVersion "${pv.qualifiedVersionKey}" has no matching public archive file.';
1076+
yield 'PackageVersion "${pv.qualifiedVersionKey}" has no matching public archive file '
1077+
'(Package: $isPackageVisible, PackageVersion: ${pv.isVisible}).';
10771078
}
10781079
return;
10791080
}

app/lib/shared/redis_cache.dart

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class CachePatterns {
122122

123123
Entry<bool> packageVisible(String package) => _cache
124124
.withPrefix('package-visible/')
125-
.withTTL(Duration(days: 7))
125+
.withTTL(Duration(hours: 12))
126126
.withCodec(utf8)
127127
.withCodec(json)
128128
.withCodec(wrapAsCodec(
@@ -312,7 +312,7 @@ class CachePatterns {
312312

313313
Entry<bool> publisherVisible(String publisherId) => _cache
314314
.withPrefix('publisher-visible/')
315-
.withTTL(Duration(days: 7))
315+
.withTTL(Duration(hours: 12))
316316
.withCodec(utf8)
317317
.withCodec(json)
318318
.withCodec(wrapAsCodec(
@@ -338,21 +338,6 @@ class CachePatterns {
338338
.withPrefix('search-input-completion-data-json-gz/')
339339
.withTTL(Duration(hours: 8))['-'];
340340

341-
/// Stores the flag that latest version of packages have been scanned for job entities.
342-
Entry<bool> jobHistoryLatestScanned(String service) =>
343-
jobHistoryPackageScanned(service, '');
344-
345-
/// Stores the flag that a [package]'s versions have been scanned for job entities.
346-
Entry<bool> jobHistoryPackageScanned(String service, String package) => _cache
347-
.withPrefix('job-history-package-scanned/')
348-
.withTTL(Duration(days: 7))
349-
.withCodec(utf8)
350-
.withCodec(json)
351-
.withCodec(wrapAsCodec(
352-
encode: (bool value) => value,
353-
decode: (d) => d as bool,
354-
))['$service/$package'];
355-
356341
/// Cache for index objects, used by TaskBackend.
357342
Entry<BlobIndex> taskResultIndex(String package, String version) => _cache
358343
.withPrefix('task-result-index/')

0 commit comments

Comments
 (0)