fix(plugin-storage-fs): throw a more descriptive error when a lock couldn't be acquired

This commit is contained in:
Joakim Carlstein 2023-11-17 10:50:43 +01:00
parent 552e784fc9
commit e5eec7cdf1
2 changed files with 12 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
'@emigrate/plugin-storage-fs': patch
---
Throw a more descriptive error when a file lock couldn't be acquired

View file

@ -55,11 +55,15 @@ export default function storageFs({ filename }: StorageFsOptions): StoragePlugin
async initializeStorage() { async initializeStorage() {
return { return {
async lock(migrations) { async lock(migrations) {
const fd = await fs.open(lockFilePath, 'wx'); try {
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 {