Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix validateLock being called more than once #93

Merged
merged 1 commit into from Apr 11, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/DAV/plugins/locks.js
Expand Up @@ -558,6 +558,7 @@ var jsDAV_Locks_Plugin = module.exports = jsDAV_ServerPlugin.extend({

var ret, locks;
var stopped = false;
var cbCalled = false;
var conditions = this.getIfConditions();
var self = this;

Expand All @@ -576,6 +577,7 @@ var jsDAV_Locks_Plugin = module.exports = jsDAV_ServerPlugin.extend({
if (!conditions.length && locks.length) {
ret = false;
cbvalidate(null, ret, locks[0]);
cbCalled = true;
stopped = true;
return next(Async.STOP);
}
Expand Down Expand Up @@ -681,6 +683,11 @@ var jsDAV_Locks_Plugin = module.exports = jsDAV_ServerPlugin.extend({
});
})
.end(function(err) {
if (cbCalled) {
// we must not call callback twice
return
}

if (err && !stopped)
return cbvalidate(err, false, lastLock);

Expand Down