Markdown editor improvements
This commit is contained in:
@@ -387,9 +387,29 @@ module.exports = {
|
||||
|
||||
let self = this;
|
||||
|
||||
if(_.isEmpty(entryPath) || entryPath === 'home') {
|
||||
return Promise.reject(new Error('Invalid path!'));
|
||||
}
|
||||
|
||||
return git.moveDocument(entryPath, newEntryPath).then(() => {
|
||||
return git.commitDocument(newEntryPath).then(() => {
|
||||
|
||||
// Delete old cache version
|
||||
|
||||
let oldEntryCachePath = self.getCachePath(entryPath);
|
||||
fs.unlinkAsync(oldEntryCachePath).catch((err) => { return true; });
|
||||
|
||||
// Delete old index entry
|
||||
|
||||
ws.emit('searchDel', {
|
||||
auth: WSInternalKey,
|
||||
entryPath
|
||||
});
|
||||
|
||||
// Create cache for new entry
|
||||
|
||||
return self.updateCache(newEntryPath);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -111,28 +111,7 @@ module.exports = {
|
||||
|
||||
let self = this;
|
||||
|
||||
return self._si.searchAsync({
|
||||
query: {
|
||||
AND: [{ 'entryPath': [content.entryPath] }]
|
||||
}
|
||||
}).then((results) => {
|
||||
|
||||
if(results.totalHits > 0) {
|
||||
let delIds = _.map(results.hits, 'id');
|
||||
return self._si.delAsync(delIds);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}).catch((err) => {
|
||||
|
||||
if(err.type === 'NotFoundError') {
|
||||
return true;
|
||||
} else {
|
||||
winston.error(err);
|
||||
}
|
||||
|
||||
}).then(() => {
|
||||
return self.delete(content.entryPath).then(() => {
|
||||
|
||||
return self._si.addAsync({
|
||||
entryPath: content.entryPath,
|
||||
@@ -179,6 +158,41 @@ module.exports = {
|
||||
winston.error(err);
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete an entry from the index
|
||||
*
|
||||
* @param {String} The entry path
|
||||
* @return {Promise} Promise of the operation
|
||||
*/
|
||||
delete(entryPath) {
|
||||
|
||||
let self = this;
|
||||
|
||||
return self._si.searchAsync({
|
||||
query: {
|
||||
AND: [{ 'entryPath': [entryPath] }]
|
||||
}
|
||||
}).then((results) => {
|
||||
|
||||
if(results.totalHits > 0) {
|
||||
let delIds = _.map(results.hits, 'id');
|
||||
return self._si.delAsync(delIds);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}).catch((err) => {
|
||||
|
||||
if(err.type === 'NotFoundError') {
|
||||
return true;
|
||||
} else {
|
||||
winston.error(err);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
};
|
Reference in New Issue
Block a user