sync-storage.js 596 B

1234567891011121314151617181920
  1. const _ = require('lodash')
  2. /* global WIKI */
  3. module.exports = async (targetKey) => {
  4. WIKI.logger.info(`Syncing with storage target ${targetKey}...`)
  5. try {
  6. const target = _.find(WIKI.models.storage.targets, ['key', targetKey])
  7. if (target) {
  8. await target.fn.sync()
  9. WIKI.logger.info(`Syncing with storage target ${targetKey}: [ COMPLETED ]`)
  10. } else {
  11. throw new Error('Invalid storage target. Unable to perform sync.')
  12. }
  13. } catch (err) {
  14. WIKI.logger.error(`Syncing with storage target ${targetKey}: [ FAILED ]`)
  15. WIKI.logger.error(err.message)
  16. }
  17. }