feat: scheduler storage sync
This commit is contained in:
		@@ -1,18 +1,20 @@
 | 
			
		||||
const _ = require('lodash')
 | 
			
		||||
 | 
			
		||||
/* global WIKI */
 | 
			
		||||
 | 
			
		||||
module.exports = async ({ target }) => {
 | 
			
		||||
  WIKI.logger.info(`Syncing with storage provider ${job.data.target.title}...`)
 | 
			
		||||
module.exports = async (targetKey) => {
 | 
			
		||||
  WIKI.logger.info(`Syncing with storage target ${targetKey}...`)
 | 
			
		||||
 | 
			
		||||
  // try {
 | 
			
		||||
  //   const target = require(`../modules/storage/${job.data.target.key}/storage.js`)
 | 
			
		||||
  //   target[job.data.event].call({
 | 
			
		||||
  //     config: job.data.target.config,
 | 
			
		||||
  //     mode: job.data.target.mode,
 | 
			
		||||
  //     page: job.data.page
 | 
			
		||||
  //   })
 | 
			
		||||
  //   WIKI.logger.info(`Syncing with storage provider ${job.data.target.title}: [ COMPLETED ]`)
 | 
			
		||||
  // } catch (err) {
 | 
			
		||||
  //   WIKI.logger.error(`Syncing with storage provider ${job.data.target.title}: [ FAILED ]`)
 | 
			
		||||
  //   WIKI.logger.error(err.message)
 | 
			
		||||
  // }
 | 
			
		||||
  try {
 | 
			
		||||
    const target = _.find(WIKI.models.storage.targets, ['key', targetKey])
 | 
			
		||||
    if (target) {
 | 
			
		||||
      await target.fn.sync()
 | 
			
		||||
      WIKI.logger.info(`Syncing with storage target ${targetKey}: [ COMPLETED ]`)
 | 
			
		||||
    } else {
 | 
			
		||||
      throw new Error('Invalid storage target. Unable to perform sync.')
 | 
			
		||||
    }
 | 
			
		||||
  } catch (err) {
 | 
			
		||||
    WIKI.logger.error(`Syncing with storage target ${targetKey}: [ FAILED ]`)
 | 
			
		||||
    WIKI.logger.error(err.message)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user