Skip to content

Commit

Permalink
Fix remove to not hang when the resource doesn't exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
creationix committed Jun 29, 2010
1 parent c281176 commit badf861
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/nstore.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ function nStore(filename) {
dbLength += line.length;
queueSize += line.length;
checkQueue();
} else {
var err = new Error("Cannot delete a document that does not exist");
err.errno = process.ENOENT;
callback(err);
}
},

Expand Down
7 changes: 7 additions & 0 deletions test/removeTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ users.remove("creationix", function (err) {
assert.ok(meta, "meta loaded");
});
});

expect("fail");
users.remove("baduser", function (err) {
fulfill("fail");
assert.ok(err instanceof Error, "error is an Error");
if (err.errno !== process.ENOENT) throw err;
});

0 comments on commit badf861

Please sign in to comment.