wiki/server/modules/storage/git/storage.js
/**
   * Process Files
   *
   * @param {Array<String>} files Array of files to process
   */
Process Files
@param {Array} files Array of files to process
Process Files @param { Array } files Array of files to process
async processFiles(files, user) {
    for (const item of files) {
      const contentType = pageHelper.getContentType(item.relPath)
      const fileExists = await fs.pathExists(item.file)
      if (!item.binary && contentType) {
        if (!fileExists && item.deletions > 0 && item.insertions === 0) {
          WIKI.logger.info(`(STORAGE/GIT) Page marked as deleted: ${item.relPath}`)
          const contentPath = pageHelper.getPagePath(item.relPath)
          await WIKI.models.pages.deletePage({
            user: user,
            path: contentPath.path,
            locale: contentPath.locale,
            skipStorage: true
          })
          continue
        }
        try {
          await commonDisk.processPage({
            user,
            relPath: item.relPath,
            fullPath: this.repoPath,
            contentType: contentType,
            moduleName: 'GIT'
          })
        } catch (err) {
          WIKI.logger.warn(`(STORAGE/GIT) Failed to process ${item.relPath}`)
          WIKI.logger.warn(err)
        }
      } else {
        if (!fileExists && ((item.before > 0 && item.after === 0) || (item.deletions > 0 && item.insertions === 0))) {
          WIKI.logger.info(`(STORAGE/GIT) Asset marked as deleted: ${item.relPath}`)
          const fileHash = assetHelper.generateHash(item.relPath)
          const assetToDelete = await WIKI.models.assets.query().findOne({ hash: fileHash })
          if (assetToDelete) {
            await WIKI.models.knex('assetData').where('id', assetToDelete.id).del()
            await WIKI.models.assets.query().deleteById(assetToDelete.id)
            await assetToDelete.deleteAssetCache()
          } else {
            WIKI.logger.info(`(STORAGE/GIT) Asset was not found in the DB, nothing to delete: ${item.relPath}`)
          }
          continue
        }
        try {
          await commonDisk.processAsset({
            user,
            relPath: item.relPath,
            file: item.file,
            contentType: contentType,
            moduleName: 'GIT'
          })
        } catch (err) {
          WIKI.logger.warn(`(STORAGE/GIT) Failed to process asset ${item.relPath}`)
          WIKI.logger.warn(err)
        }
      }
    }
  }
async processFiles ( files , user ) { for ( const item of files ) { const contentType = pageHelper . getContentType ( item . relPath ) const fileExists = await fs . pathExists ( item . file ) if ( ! item . binary && contentType ) { if ( ! fileExists && item . deletions > 0 && item . insertions === 0 ) { WIKI . logger . info ( ` ${ item . relPath } ` ) const contentPath = pageHelper . getPagePath ( item . relPath ) await WIKI . models . pages . deletePage ( { user : user , path : contentPath . path , locale : contentPath . locale , skipStorage : true } ) continue } try { await commonDisk . processPage ( { user , relPath : item . relPath , fullPath : this . repoPath , contentType : contentType , moduleName : 'GIT' } ) } catch ( err ) { WIKI . logger . warn ( ` ${ item . relPath } ` ) WIKI . logger . warn ( err ) } } else { if ( ! fileExists && ( ( item . before > 0 && item . after === 0 ) || ( item . deletions > 0 && item . insertions === 0 ) ) ) { WIKI . logger . info ( ` ${ item . relPath } ` ) const fileHash = assetHelper . generateHash ( item . relPath ) const assetToDelete = await WIKI . models . assets . query ( ) . findOne ( { hash : fileHash } ) if ( assetToDelete ) { await WIKI . models . knex ( 'assetData' ) . where ( 'id' , assetToDelete . id ) . del ( ) await WIKI . models . assets . query ( ) . deleteById ( assetToDelete . id ) await assetToDelete . deleteAssetCache ( ) } else { WIKI . logger . info ( ` ${ item . relPath } ` ) } continue } try { await commonDisk . processAsset ( { user , relPath : item . relPath , file : item . file , contentType : contentType , moduleName : 'GIT' } ) } catch ( err ) { WIKI . logger . warn ( ` ${ item . relPath } ` ) WIKI . logger . warn ( err ) } } } }
Process Files
 @param {Array<String>} files Array of files to process
Process Files @param { Array<String > } files Array of files to process
// -> Page // Page was deleted by git, can safely mark as deleted in DB // -> Asset // Asset was deleted by git, can safely mark as deleted in DB