%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /data/old/usr/lib/node_modules/hexo/lib/hexo/
Upload File :
Create Path :
Current File : //data/old/usr/lib/node_modules/hexo/lib/hexo/load_database.js

'use strict';

const fs = require('hexo-fs');
const Promise = require('bluebird');

module.exports = ctx => {
  if (ctx._dbLoaded) return Promise.resolve();

  const db = ctx.database;
  const { path } = db.options;
  const { log } = ctx;

  return fs.exists(path).then(exist => {
    if (!exist) return;

    log.debug('Loading database.');
    return db.load();
  }).then(() => {
    ctx._dbLoaded = true;
  }).catch(() => {
    log.error('Database load failed. Deleting database.');
    return fs.unlink(path);
  });
};

Zerion Mini Shell 1.0