|
@@ -185,36 +185,43 @@ module.exports = function(crowi, app) {
|
|
|
return res.redirect('/admin');
|
|
return res.redirect('/admin');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- search.deleteIndex()
|
|
|
|
|
- .then(function(data) {
|
|
|
|
|
- if (!data.errors) {
|
|
|
|
|
- debug('Index deleted.');
|
|
|
|
|
- }
|
|
|
|
|
- return search.buildIndex();
|
|
|
|
|
- })
|
|
|
|
|
- .then(function(data) {
|
|
|
|
|
- if (!data.errors) {
|
|
|
|
|
- debug('Index created.');
|
|
|
|
|
- }
|
|
|
|
|
- return search.addAllPages();
|
|
|
|
|
- })
|
|
|
|
|
- .then(function(data) {
|
|
|
|
|
- if (!data.errors) {
|
|
|
|
|
- debug('Data is successfully indexed.');
|
|
|
|
|
- } else {
|
|
|
|
|
- debug('Data index error.', data);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //return res.json(ApiResponse.success({}));
|
|
|
|
|
- req.flash('successMessage', 'Successfully re-build index.');
|
|
|
|
|
- return res.redirect('/admin/search');
|
|
|
|
|
- })
|
|
|
|
|
- .catch(function(err) {
|
|
|
|
|
- debug('Error', err);
|
|
|
|
|
- req.flash('errorMessage', 'Error');
|
|
|
|
|
- return res.redirect('/admin/search');
|
|
|
|
|
- //return res.json(ApiResponse.error(err));
|
|
|
|
|
|
|
+ Promise.resolve().then(function() {
|
|
|
|
|
+ return new Promise(function(resolve, reject) {
|
|
|
|
|
+ search.deleteIndex()
|
|
|
|
|
+ .then(function(data) {
|
|
|
|
|
+ debug('Index deleted.');
|
|
|
|
|
+ resolve();
|
|
|
|
|
+ }).catch(function(err) {
|
|
|
|
|
+ debug('Delete index Error, but if it is initialize, its ok.', err);
|
|
|
|
|
+ resolve();
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
|
|
+ }).then(function() {
|
|
|
|
|
+ search.buildIndex()
|
|
|
|
|
+ .then(function(data) {
|
|
|
|
|
+ if (!data.errors) {
|
|
|
|
|
+ debug('Index created.');
|
|
|
|
|
+ }
|
|
|
|
|
+ return search.addAllPages();
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(function(data) {
|
|
|
|
|
+ if (!data.errors) {
|
|
|
|
|
+ debug('Data is successfully indexed.');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ debug('Data index error.', data);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //return res.json(ApiResponse.success({}));
|
|
|
|
|
+ req.flash('successMessage', 'Successfully re-build index.');
|
|
|
|
|
+ return res.redirect('/admin/search');
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(function(err) {
|
|
|
|
|
+ debug('Error', err);
|
|
|
|
|
+ req.flash('errorMessage', 'Error');
|
|
|
|
|
+ return res.redirect('/admin/search');
|
|
|
|
|
+ //return res.json(ApiResponse.error(err));
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
actions.user = {};
|
|
actions.user = {};
|