@@ -10,7 +10,6 @@ import 'package:pub_dev/package/backend.dart';
1010import 'package:pub_dev/shared/configuration.dart' ;
1111import 'package:pub_dev/shared/datastore.dart' ;
1212import 'package:pub_dev/shared/utils.dart' ;
13- import 'package:pub_dev/shared/versions.dart' show runtimeVersion;
1413import 'package:pub_dev/task/backend.dart' ;
1514import 'package:pub_dev/task/clock_control.dart' ;
1615import 'package:pub_dev/task/cloudcompute/cloudcompute.dart' ;
@@ -237,26 +236,11 @@ Future<void> schedule(
237236 // suppose to run on the instance we just failed to create.
238237 // If this doesn't work, we'll eventually retry. Hence, correctness
239238 // does not hinge on this transaction being successful.
240- await withRetryTransaction (db, (tx) async {
241- final s = await tx.lookupOrNull <PackageState >(
242- PackageState .createKey (
243- db.emptyKey,
244- runtimeVersion,
245- selected.package,
246- ),
247- );
248- if (s == null ) {
249- return ; // Presumably, the package was deleted.
250- }
251-
252- s.versions! .addEntries (
253- s.versions! .entries
254- .where ((e) => e.value.instance == instanceName)
255- .map ((e) => MapEntry (e.key, oldVersionsMap[e.key]! )),
256- );
257- s.derivePendingAt ();
258- tx.insert (s);
259- });
239+ await db.tasks.restorePreviousVersionsState (
240+ selected.package,
241+ instanceName,
242+ oldVersionsMap,
243+ );
260244 }
261245 }
262246 });
@@ -295,9 +279,7 @@ updatePackageStateWithPendingVersions(
295279 String instanceName,
296280) async {
297281 return await withRetryTransaction (db, (tx) async {
298- final s = await tx.lookupOrNull <PackageState >(
299- PackageState .createKey (db.emptyKey, runtimeVersion, package),
300- );
282+ final s = await tx.tasks.lookupOrNull (package);
301283 if (s == null ) {
302284 // presumably the package was deleted.
303285 return null ;
@@ -360,7 +342,7 @@ updatePackageStateWithPendingVersions(
360342 ),
361343 });
362344 s.derivePendingAt ();
363- tx.insert (s);
345+ await tx.tasks. update (s);
364346
365347 // Create payload
366348 final payload = Payload (
0 commit comments