fix(plugin-storage-fs): throw a more descriptive error when a lock couldn't be acquired
This commit is contained in:
parent
552e784fc9
commit
e5eec7cdf1
2 changed files with 12 additions and 3 deletions
5
.changeset/calm-windows-drum.md
Normal file
5
.changeset/calm-windows-drum.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@emigrate/plugin-storage-fs': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Throw a more descriptive error when a file lock couldn't be acquired
|
||||||
|
|
@ -55,11 +55,15 @@ export default function storageFs({ filename }: StorageFsOptions): StoragePlugin
|
||||||
async initializeStorage() {
|
async initializeStorage() {
|
||||||
return {
|
return {
|
||||||
async lock(migrations) {
|
async lock(migrations) {
|
||||||
|
try {
|
||||||
const fd = await fs.open(lockFilePath, 'wx');
|
const fd = await fs.open(lockFilePath, 'wx');
|
||||||
|
|
||||||
await fd.close();
|
await fd.close();
|
||||||
|
|
||||||
return migrations;
|
return migrations;
|
||||||
|
} catch {
|
||||||
|
throw new Error('Could not acquire file lock for migrations');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async unlock() {
|
async unlock() {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue