Skip to content

Commit 5d48f02

Browse files
committed
log state lock acquisition
1 parent f03b487 commit 5d48f02

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/services/GithubService.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ export class GithubService {
105105
const tokenSha = crypto.createHash('sha256').update(auth).digest().toString('base64');
106106

107107
console.log(
108-
`Inferring identity (auth: ${auth} sha: ${tokenSha} owner: ${owner}, repo: ${repo}, workspace: ${workspace}, stateLockRequest: ${JSON.stringify(
108+
`Inferring identity (auth: ${auth.substring(
109+
0,
110+
10,
111+
)} sha: ${tokenSha} owner: ${owner}, repo: ${repo}, workspace: ${workspace}, stateLockRequest: ${JSON.stringify(
109112
stateLockRequest,
110113
)})`,
111114
);

src/services/StateService.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,12 @@ export class StateService {
118118
const lockedBy = crypto.createHash('sha256').update(identity.token, 'utf8').digest('base64');
119119
const path = stateLockRequest.Path || '';
120120

121-
let stateLock = await this.stateLockModel.model.get(
122-
StateLockModel.prefix('pk', identity.ownerId),
123-
StateLockModel.prefix('sk', `${identity.repoId}_${identity.workspace}_${path}`),
124-
);
121+
const pk = StateLockModel.prefix('pk', identity.ownerId);
122+
const sk = StateLockModel.prefix('sk', `${identity.repoId}_${identity.workspace}_${path}`);
123+
124+
console.log(`Acquiring state lock (pk: ${pk} sk: ${sk})`);
125+
126+
let stateLock = await this.stateLockModel.model.get(pk, sk);
125127

126128
if (stateLock && stateLock.attrs.lockedBy !== lockedBy) {
127129
console.warn(
@@ -132,8 +134,8 @@ export class StateService {
132134

133135
// TODO Catch overwrite exception
134136
stateLock = await this.stateLockModel.model.create({
135-
pk: StateLockModel.prefix('pk', identity.ownerId),
136-
sk: StateLockModel.prefix('sk', `${identity.repoId}_${identity.workspace}_${path}`),
137+
pk,
138+
sk,
137139
ownerId: identity.ownerId,
138140
owner: identity.owner,
139141
repoId: identity.repoId,

0 commit comments

Comments
 (0)