From 04660769ec5c8af1c50f6fe719504d7bc3be711c Mon Sep 17 00:00:00 2001 From: Jonas Finnemann Jensen Date: Fri, 18 Oct 2024 14:34:16 +0200 Subject: [PATCH] Lookup SDK versions concurrently --- app/lib/package/backend.dart | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/lib/package/backend.dart b/app/lib/package/backend.dart index b409cec56f..e0bf66f8bf 100644 --- a/app/lib/package/backend.dart +++ b/app/lib/package/backend.dart @@ -1073,13 +1073,12 @@ class PackageBackend { }) async { final sw = Stopwatch()..start(); final newVersion = entities.packageVersion; - final currentDartSdk = await getCachedDartSdkVersion( - lastKnownStable: toolStableDartSdkVersion); - final currentFlutterSdk = await getCachedFlutterSdkVersion( - lastKnownStable: toolStableFlutterSdkVersion); + final [currentDartSdk, currentFlutterSdk] = await Future.wait([ + getCachedDartSdkVersion(lastKnownStable: toolStableDartSdkVersion), + getCachedFlutterSdkVersion(lastKnownStable: toolStableFlutterSdkVersion), + ]); final existingPackage = await lookupPackage(newVersion.package); final isNew = existingPackage == null; - // check authorizations before the transaction await _requireUploadAuthorization( agent, existingPackage, newVersion.version!); @@ -1102,14 +1101,12 @@ class PackageBackend { throw AssertionError( 'Package "${newVersion.package}" has no admin email to notify.'); } - // check rate limits before the transaction await verifyPackageUploadRateLimit( agent: agent, package: newVersion.package, isNew: isNew, ); - final email = createPackageUploadedEmail( packageName: newVersion.package, packageVersion: newVersion.version!, @@ -1118,7 +1115,6 @@ class PackageBackend { uploaderEmails.map((email) => EmailAddress(email)).toList(), ); final outgoingEmail = emailBackend.prepareEntity(email); - Package? package; final existingVersions = await db .query(ancestorKey: newVersion.packageKey!)