Commit 55771659 authored by Sacha Brants's avatar Sacha Brants
Browse files

fix: release the lock in case the dataset does not exist

parent c6e79f42
...@@ -822,10 +822,17 @@ export class DatasetHandler { ...@@ -822,10 +822,17 @@ export class DatasetHandler {
// check if the dataset does not exist // check if the dataset does not exist
const lockKey = datasetIN.tenant + '/' + datasetIN.subproject + datasetIN.path + datasetIN.name;
if (!dataset) { if (!dataset) {
throw (Error.make(Error.Status.NOT_FOUND, if(await Locker.getLock(lockKey)) {
'The dataset ' + Config.SDPATHPREFIX + datasetIN.tenant + '/' + // if a previous call fails, the dataset is not created but the lock is acquired and not released
datasetIN.subproject + datasetIN.path + datasetIN.name + ' does not exist')); await Locker.unlock(lockKey);
return;
} else { // the dataset does not exist and is not locked
throw (Error.make(Error.Status.NOT_FOUND,
'The dataset ' + Config.SDPATHPREFIX + datasetIN.tenant + '/' +
datasetIN.subproject + datasetIN.path + datasetIN.name + ' does not exist'));
}
} }
// check if user is write authorized // check if user is write authorized
...@@ -845,7 +852,6 @@ export class DatasetHandler { ...@@ -845,7 +852,6 @@ export class DatasetHandler {
authGroups, tenant, dataset.subproject, req[Config.DE_FORWARD_APPKEY]); authGroups, tenant, dataset.subproject, req[Config.DE_FORWARD_APPKEY]);
// unlock // unlock
const lockKey = datasetIN.tenant + '/' + datasetIN.subproject + datasetIN.path + datasetIN.name;
await Locker.unlock(lockKey); await Locker.unlock(lockKey);
} }
......
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