var fs = require('fs-extra');
var file = require('./util/file');

module.exports = {
    load() {
    },

    unload() {
    },

    replaceDirUuid: function (path, dbpath) {
        Editor.log('开始检查:' + path);
        file.findDirUuid(path);
        Editor.log('资源检查完成');
    },

    messages: {
        'checkFileName'() {
            var uuids = Editor.Selection.curSelection('asset');
            uuids.forEach((uuid) => {
                var dir_path = Editor.assetdb._uuid2path[uuid];
                if (fs.existsSync(dir_path)) {
                    this.replaceDirUuid(dir_path, Editor.assetdb.uuidToUrl(uuid));
                }
            });
        },
    },
}