mirror of
https://github.com/SunRed/haste-server.git
synced 2024-11-01 01:30:21 +01:00
Catch exceptions
This commit is contained in:
parent
83b8f3f52d
commit
a83ae523b4
1 changed files with 14 additions and 5 deletions
|
@ -11,12 +11,21 @@ var FileDocumentStore = function(options) {
|
||||||
|
|
||||||
// Save data in a file, key as md5 - since we don't know what we could be passed here
|
// Save data in a file, key as md5 - since we don't know what we could be passed here
|
||||||
FileDocumentStore.prototype.set = function(key, data, callback) {
|
FileDocumentStore.prototype.set = function(key, data, callback) {
|
||||||
var _this = this;
|
try {
|
||||||
fs.mkdir(this.basePath, '700', function() {
|
var _this = this;
|
||||||
fs.writeFile(_this.basePath + '/' + hashlib.md5(key), data, 'utf8', function() {
|
fs.mkdir(this.basePath, '700', function() {
|
||||||
callback(true); // TODO handle errors
|
fs.writeFile(_this.basePath + '/' + hashlib.md5(key), data, 'utf8', function(err) {
|
||||||
|
if (err) {
|
||||||
|
callback(false);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
callback(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
} catch(err) {
|
||||||
|
callback(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get data from a file from key
|
// Get data from a file from key
|
||||||
|
|
Loading…
Reference in a new issue