Commit 1d526cab authored by nanahira's avatar nanahira

fix lock

parent 5f6e618a
Pipeline #23582 passed with stages
in 4 minutes and 36 seconds
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
"@nestjs/swagger": "^5.0.9", "@nestjs/swagger": "^5.0.9",
"@nestjs/typeorm": "^8.0.2", "@nestjs/typeorm": "^8.0.2",
"axios": "^0.21.1", "axios": "^0.21.1",
"better-lock": "^2.0.3",
"busboy": "^0.2.14", "busboy": "^0.2.14",
"class-transformer": "^0.4.0", "class-transformer": "^0.4.0",
"class-validator": "^0.13.1", "class-validator": "^0.13.1",
...@@ -4202,6 +4203,11 @@ ...@@ -4202,6 +4203,11 @@
} }
] ]
}, },
"node_modules/better-lock": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/better-lock/-/better-lock-2.0.3.tgz",
"integrity": "sha512-3bCaToLrmEXZcIOOVWgi1STvp3/6EpoZAmlWBeuX2MvDB0Ql2ctl/vQ0CbhQIJYQiptdGypllP3ez+TeEmdnKQ=="
},
"node_modules/binary-extensions": { "node_modules/binary-extensions": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
...@@ -15207,6 +15213,11 @@ ...@@ -15207,6 +15213,11 @@
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
}, },
"better-lock": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/better-lock/-/better-lock-2.0.3.tgz",
"integrity": "sha512-3bCaToLrmEXZcIOOVWgi1STvp3/6EpoZAmlWBeuX2MvDB0Ql2ctl/vQ0CbhQIJYQiptdGypllP3ez+TeEmdnKQ=="
},
"binary-extensions": { "binary-extensions": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
"@nestjs/swagger": "^5.0.9", "@nestjs/swagger": "^5.0.9",
"@nestjs/typeorm": "^8.0.2", "@nestjs/typeorm": "^8.0.2",
"axios": "^0.21.1", "axios": "^0.21.1",
"better-lock": "^2.0.3",
"busboy": "^0.2.14", "busboy": "^0.2.14",
"class-transformer": "^0.4.0", "class-transformer": "^0.4.0",
"class-validator": "^0.13.1", "class-validator": "^0.13.1",
......
...@@ -17,6 +17,7 @@ import { createHash } from 'crypto'; ...@@ -17,6 +17,7 @@ import { createHash } from 'crypto';
import PQueue from 'p-queue'; import PQueue from 'p-queue';
import { LockService } from 'src/lock/lock.service'; import { LockService } from 'src/lock/lock.service';
import { InjectRedis, Redis } from '@nestjs-modules/ioredis'; import { InjectRedis, Redis } from '@nestjs-modules/ioredis';
import BetterLock from 'better-lock';
interface FileWithHash { interface FileWithHash {
file: readdirp.EntryInfo; file: readdirp.EntryInfo;
...@@ -208,6 +209,8 @@ export class PackagerService extends ConsoleLogger { ...@@ -208,6 +209,8 @@ export class PackagerService extends ConsoleLogger {
]); ]);
} }
private localLock = new BetterLock();
async archive(root: string, archiveTask: ArchiveTask): Promise<Archive> { async archive(root: string, archiveTask: ArchiveTask): Promise<Archive> {
return this.redlock.getLockInstance().using([`archive:${archiveTask.path}`], 5000, async () => this.archiveProcess(root, archiveTask)); return this.redlock.getLockInstance().using([`archive:${archiveTask.path}`], 5000, async () => this.archiveProcess(root, archiveTask));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment