File tree Expand file tree Collapse file tree 2 files changed +25
-7
lines changed
Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ Future<S5> initS5(
2929 if (! s5.hasIdentity) {
3030 String seed = "" ;
3131 if (inputSeed != null ) {
32+ // first validate the seed
33+ validatePhrase (inputSeed, crypto: s5.api.crypto);
3234 seed = inputSeed;
3335 } else {
3436 seed = s5.generateSeedPhrase ();
@@ -45,11 +47,20 @@ Future<S5> initS5(
4547 }
4648 setConfig (DeployConfig (seed: seed, dataKeys: []));
4749 await s5.recoverIdentityFromSeedPhrase (seed);
48- // if (inputSeed == null) {
49- await s5.registerOnNewStorageService (
50- nodeURL,
51- );
52- // }
50+
51+ // then check if already registered
52+ Map <dynamic , dynamic > data = (s5.api as S5NodeAPIWithIdentity ).accounts;
53+ final Map <String , dynamic > accounts =
54+ data['accounts' ] as Map <String , dynamic >;
55+ final List <String > urls =
56+ accounts.values.map ((account) => account['url' ] as String ).toList ();
57+ // And if the nodeURL isn't on the seed already, authenticate on that server
58+ if (! urls.contains (nodeURL)) {
59+ print ("Registering @ $nodeURL " );
60+ await s5.registerOnNewStorageService (
61+ nodeURL,
62+ );
63+ }
5364 }
5465 return s5;
5566}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import 'dart:io';
33import 'package:args/args.dart' ;
44import 'package:cli_spin/cli_spin.dart' ;
55import 'package:dcli/dcli.dart' ;
6+ import 'package:lib5/identity.dart' ;
67import 'package:lib5/node.dart' ;
78import 'package:mime/mime.dart' ;
89import 'package:path/path.dart' ;
@@ -70,8 +71,14 @@ void s5Deploy(List<String> args) async {
7071 // init s5
7172 spinner = spinStart ("Initializing S5..." );
7273 String nodeURL = results['node' ] as String ;
73- final S5 s5 =
74- await initS5 (nodeURL, dbPath, logPath, (results['seed' ] as String ? ));
74+ late S5 s5;
75+ try {
76+ s5 = await initS5 (nodeURL, dbPath, logPath, (results['seed' ] as String ? ));
77+ } catch (e) {
78+ spinner.fail ();
79+ print (red (e.toString ()));
80+ }
81+
7582 spinner.success ();
7683
7784 // scan directory
You can’t perform that action at this time.
0 commit comments