Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions app/lib/frontend/handlers/package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -300,17 +300,12 @@ Future<shelf.Response> _handlePackagePage({

if (cachedPage == null) {
final package = await packageBackend.lookupPackage(packageName);
if (package == null || !package.isVisible) {
if (package?.isModerated ?? false) {
final content = renderModeratedPackagePage(packageName);
return htmlResponse(content, status: 404);
}
if (await packageBackend.isPackageModerated(packageName)) {
final content = renderModeratedPackagePage(packageName);
return htmlResponse(content, status: 404);
} else {
return formattedNotFoundHandler(request);
}
if (package == null) {
return formattedNotFoundHandler(request);
}
if (package.isNotVisible) {
final content = renderModeratedPackagePage(packageName);
return htmlResponse(content, status: 404);
}
final serviceSw = Stopwatch()..start();
final PackagePageData data;
Expand Down
13 changes: 0 additions & 13 deletions app/lib/package/backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,6 @@ class PackageBackend {
}))!;
}

/// Whether the package has been deleted and a [ModeratedPackage] entity exists for it.
Future<bool> isPackageModerated(String package) async {
return (await cache.packageModerated(package).get(() async {
final visible = await isPackageVisible(package);
if (visible) {
return false;
}
final p = await lookupModeratedPackage(package);
return p != null;
}))!;
}

Stream<Package> allPackages() => db.query<Package>().run();

Stream<String> allPackageNames() {
Expand Down Expand Up @@ -1769,7 +1757,6 @@ api.PackagePublisherInfo _asPackagePublisherInfo(Package p) =>
Future<void> purgePackageCache(String package) async {
await Future.wait([
cache.packageVisible(package).purge(),
cache.packageModerated(package).purge(),
cache.packageData(package).purge(),
cache.packageDataGz(package).purge(),
cache.packageLatestVersion(package).purge(),
Expand Down
10 changes: 0 additions & 10 deletions app/lib/shared/redis_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,6 @@ class CachePatterns {
decode: (d) => d as bool,
))[package];

Entry<bool> packageModerated(String package) => _cache
.withPrefix('package-moderated/')
.withTTL(Duration(days: 7))
.withCodec(utf8)
.withCodec(json)
.withCodec(wrapAsCodec(
encode: (bool value) => value,
decode: (d) => d as bool,
))[package];

Entry<List<int>> packageData(String package) => _cache
.withPrefix('api-package-data-by-uri/')
.withTTL(Duration(minutes: 10))['$package'];
Expand Down