@abtnode/core 1.16.25-next-4f765cf3 → 1.16.25-next-a0747dd3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/team/manager.js +10 -8
  2. package/package.json +20 -20
@@ -25,8 +25,6 @@ const {
25
25
 
26
26
  const { isCLI, getDbFilePath } = require('../util');
27
27
 
28
- const rbacCreationLock = new Lock('rbac-creation-lock');
29
-
30
28
  const States = {
31
29
  User: require('../states/user'),
32
30
  UserSession: require('../states/user-session'),
@@ -203,8 +201,8 @@ class TeamManager extends EventEmitter {
203
201
  throw new Error('Blocklet Server rbac instance has not been initialized');
204
202
  }
205
203
 
206
- // FIXME: cross process lock
207
- await rbacCreationLock.acquire();
204
+ const lock = Lock.getLock(`init-rbac-${did}`);
205
+ await lock.acquire();
208
206
  try {
209
207
  logger.info('create rbac', { did });
210
208
  const models = await this.getModels(did);
@@ -221,10 +219,10 @@ class TeamManager extends EventEmitter {
221
219
  }
222
220
  }
223
221
 
224
- rbacCreationLock.release();
222
+ lock.release();
225
223
  return rbac;
226
224
  } catch (error) {
227
- rbacCreationLock.release();
225
+ lock.release();
228
226
  throw error;
229
227
  }
230
228
  }
@@ -441,6 +439,8 @@ class TeamManager extends EventEmitter {
441
439
  return;
442
440
  }
443
441
 
442
+ const lock = Lock.getLock(`init-database-${did}`);
443
+ await lock.acquire();
444
444
  const dbPath = await this.getDataFileByDid(did);
445
445
  logger.info('initDatabase', { did, dbPath });
446
446
  try {
@@ -448,6 +448,8 @@ class TeamManager extends EventEmitter {
448
448
  } catch (error) {
449
449
  // This error is not fatal, just log it, will happen when there are multiple service processes
450
450
  logger.error('initDatabase failed', { did, dbPath, error });
451
+ } finally {
452
+ lock.release();
451
453
  }
452
454
  }
453
455
 
@@ -458,11 +460,11 @@ class TeamManager extends EventEmitter {
458
460
  async getOwnerAndAdminUsers(did, approved) {
459
461
  const passportState = await this.getPassportState(did);
460
462
 
461
- const passorts = await passportState.find({
463
+ const passports = await passportState.find({
462
464
  where: { [Op.or]: [{ role: 'owner' }, { role: 'admin' }] },
463
465
  attributes: ['userDid'],
464
466
  });
465
- const userDids = passorts.map((d) => d.userDid);
467
+ const userDids = passports.map((d) => d.userDid);
466
468
 
467
469
  const userState = await this.getUserState(did);
468
470
  const users = await userState.find({
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.25-next-4f765cf3",
6
+ "version": "1.16.25-next-a0747dd3",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,19 +19,19 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
- "@abtnode/analytics": "1.16.25-next-4f765cf3",
23
- "@abtnode/auth": "1.16.25-next-4f765cf3",
24
- "@abtnode/certificate-manager": "1.16.25-next-4f765cf3",
25
- "@abtnode/constant": "1.16.25-next-4f765cf3",
26
- "@abtnode/cron": "1.16.25-next-4f765cf3",
27
- "@abtnode/logger": "1.16.25-next-4f765cf3",
28
- "@abtnode/models": "1.16.25-next-4f765cf3",
29
- "@abtnode/queue": "1.16.25-next-4f765cf3",
30
- "@abtnode/rbac": "1.16.25-next-4f765cf3",
31
- "@abtnode/router-provider": "1.16.25-next-4f765cf3",
32
- "@abtnode/static-server": "1.16.25-next-4f765cf3",
33
- "@abtnode/timemachine": "1.16.25-next-4f765cf3",
34
- "@abtnode/util": "1.16.25-next-4f765cf3",
22
+ "@abtnode/analytics": "1.16.25-next-a0747dd3",
23
+ "@abtnode/auth": "1.16.25-next-a0747dd3",
24
+ "@abtnode/certificate-manager": "1.16.25-next-a0747dd3",
25
+ "@abtnode/constant": "1.16.25-next-a0747dd3",
26
+ "@abtnode/cron": "1.16.25-next-a0747dd3",
27
+ "@abtnode/logger": "1.16.25-next-a0747dd3",
28
+ "@abtnode/models": "1.16.25-next-a0747dd3",
29
+ "@abtnode/queue": "1.16.25-next-a0747dd3",
30
+ "@abtnode/rbac": "1.16.25-next-a0747dd3",
31
+ "@abtnode/router-provider": "1.16.25-next-a0747dd3",
32
+ "@abtnode/static-server": "1.16.25-next-a0747dd3",
33
+ "@abtnode/timemachine": "1.16.25-next-a0747dd3",
34
+ "@abtnode/util": "1.16.25-next-a0747dd3",
35
35
  "@arcblock/did": "1.18.113",
36
36
  "@arcblock/did-auth": "1.18.113",
37
37
  "@arcblock/did-ext": "^1.18.113",
@@ -42,11 +42,11 @@
42
42
  "@arcblock/pm2-events": "^0.0.5",
43
43
  "@arcblock/validator": "^1.18.113",
44
44
  "@arcblock/vc": "1.18.113",
45
- "@blocklet/constant": "1.16.25-next-4f765cf3",
46
- "@blocklet/env": "1.16.25-next-4f765cf3",
47
- "@blocklet/meta": "1.16.25-next-4f765cf3",
48
- "@blocklet/resolver": "1.16.25-next-4f765cf3",
49
- "@blocklet/sdk": "1.16.25-next-4f765cf3",
45
+ "@blocklet/constant": "1.16.25-next-a0747dd3",
46
+ "@blocklet/env": "1.16.25-next-a0747dd3",
47
+ "@blocklet/meta": "1.16.25-next-a0747dd3",
48
+ "@blocklet/resolver": "1.16.25-next-a0747dd3",
49
+ "@blocklet/sdk": "1.16.25-next-a0747dd3",
50
50
  "@did-space/client": "^0.3.67",
51
51
  "@fidm/x509": "^1.2.1",
52
52
  "@ocap/mcrypto": "1.18.113",
@@ -102,5 +102,5 @@
102
102
  "jest": "^29.7.0",
103
103
  "unzipper": "^0.10.11"
104
104
  },
105
- "gitHead": "acc090d310154d381747b0586133724ef09229fd"
105
+ "gitHead": "1b8ffe184a925ffac92f6b06eaaaf775d2923bb6"
106
106
  }