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

Merge branch 'slb/sb/fix-unlock' into 'master'

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

See merge request !156
parents c6e79f42 55771659
Pipeline #55250 passed with stages
in 7 minutes and 46 seconds
......@@ -822,10 +822,17 @@ export class DatasetHandler {
// check if the dataset does not exist
const lockKey = datasetIN.tenant + '/' + datasetIN.subproject + datasetIN.path + datasetIN.name;
if (!dataset) {
throw (Error.make(Error.Status.NOT_FOUND,
'The dataset ' + Config.SDPATHPREFIX + datasetIN.tenant + '/' +
datasetIN.subproject + datasetIN.path + datasetIN.name + ' does not exist'));
if(await Locker.getLock(lockKey)) {
// if a previous call fails, the dataset is not created but the lock is acquired and not released
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
......@@ -845,7 +852,6 @@ export class DatasetHandler {
authGroups, tenant, dataset.subproject, req[Config.DE_FORWARD_APPKEY]);
// unlock
const lockKey = datasetIN.tenant + '/' + datasetIN.subproject + datasetIN.path + datasetIN.name;
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