@@ -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' ;
@@ -236,26 +235,11 @@ Future<void> schedule(
236235 // suppose to run on the instance we just failed to create.
237236 // If this doesn't work, we'll eventually retry. Hence, correctness
238237 // does not hinge on this transaction being successful.
239- await withRetryTransaction (db, (tx) async {
240- final s = await tx.lookupOrNull <PackageState >(
241- PackageState .createKey (
242- db.emptyKey,
243- runtimeVersion,
244- selected.package,
245- ),
246- );
247- if (s == null ) {
248- return ; // Presumably, the package was deleted.
249- }
250-
251- s.versions! .addEntries (
252- s.versions! .entries
253- .where ((e) => e.value.instance == instanceName)
254- .map ((e) => MapEntry (e.key, oldVersionsMap[e.key]! )),
255- );
256- s.derivePendingAt ();
257- tx.insert (s);
258- });
238+ await db.tasks.restorePreviousVersionsState (
239+ selected.package,
240+ instanceName,
241+ oldVersionsMap,
242+ );
259243 }
260244 }
261245 });
@@ -294,9 +278,7 @@ updatePackageStateWithPendingVersions(
294278 String instanceName,
295279) async {
296280 return await withRetryTransaction (db, (tx) async {
297- final s = await tx.lookupOrNull <PackageState >(
298- PackageState .createKey (db.emptyKey, runtimeVersion, package),
299- );
281+ final s = await tx.tasks.lookupOrNull (package);
300282 if (s == null ) {
301283 // presumably the package was deleted.
302284 return null ;
@@ -323,7 +305,7 @@ updatePackageStateWithPendingVersions(
323305 ),
324306 });
325307 s.derivePendingAt ();
326- tx.insert (s);
308+ await tx.tasks. update (s);
327309
328310 // Create payload
329311 final payload = Payload (
0 commit comments