src/bin/blob_fs_clean_up.js
function cleanUp(options) {
    var BlobClient = require('../server/middleware/blob/BlobClientWithFSBackend'),
        blobClient,
        logger,
        gmeAuth,
        error,
        storage;

    if (options && options.env) {
        process.env.NODE_ENV = options.env;
    }
    gmeConfig = require(path.join(process.cwd(), 'config'));
    webgme.addToRequireJsPaths(gmeConfig);
    logger = webgme.Logger.create('clean_up', gmeConfig.bin.log, false);
    blobClient = new BlobClient(gmeConfig, logger);

    options = options || {};

    return webgme.getGmeAuth(gmeConfig)
        .then(function (gmeAuth_) {
            gmeAuth = gmeAuth_;
            storage = webgme.getStorage(logger, gmeConfig, gmeAuth);

            return storage.openDatabase();
        })
        .then(function () {
            if (options.input) {
                return getInputHashes(options.input);
            } else {
                return getUnusedMetaHashes(blobClient, gmeAuth.metadataStorage, storage);
            }
        })
        .then(function (unusedMetaHashes) {
            if (options.del !== true && !options.input) {
                console.log('The following metaDataHashes are unused:');
                console.log(unusedMetaHashes);
                return null;
            } else {
                return removeBasedOnMetaHashes(blobClient, unusedMetaHashes);
            }
        })
        .then(function (removals) {
            if (removals) {
                console.log('The following items were removed:');
                console.log(JSON.stringify(removals, null, 2));
            }
        })
        .catch(function (err_) {
            error = err_;
        })
        .finally(function () {
            logger.debug('Closing database connections...');
            return Q.allSettled([storage.closeDatabase(), gmeAuth.unload()])
                .finally(function () {
                    logger.debug('Closed.');
                    if (error) {
                        throw error;
                    }
                });
        });
}
function cleanUp(options) {
    var BlobClient = require('../server/middleware/blob/BlobClientWithFSBackend'),
        blobClient,
        logger,
        gmeAuth,
        error,
        storage;

    if (options && options.env) {
        process.env.NODE_ENV = options.env;
    }
    gmeConfig = require(path.join(process.cwd(), 'config'));
    webgme.addToRequireJsPaths(gmeConfig);
    logger = webgme.Logger.create('clean_up', gmeConfig.bin.log, false);
    blobClient = new BlobClient(gmeConfig, logger);

    options = options || {};

    return webgme.getGmeAuth(gmeConfig)
        .then(function (gmeAuth_) {
            gmeAuth = gmeAuth_;
            storage = webgme.getStorage(logger, gmeConfig, gmeAuth);

            return storage.openDatabase();
        })
        .then(function () {
            if (options.input) {
                return getInputHashes(options.input);
            } else {
                return getUnusedMetaHashes(blobClient, gmeAuth.metadataStorage, storage);
            }
        })
        .then(function (unusedMetaHashes) {
            if (options.del !== true && !options.input) {
                console.log('The following metaDataHashes are unused:');
                console.log(unusedMetaHashes);
                return null;
            } else {
                return removeBasedOnMetaHashes(blobClient, unusedMetaHashes);
            }
        })
        .then(function (removals) {
            if (removals) {
                console.log('The following items were removed:');
                console.log(JSON.stringify(removals, null, 2));
            }
        })
        .catch(function (err_) {
            error = err_;
        })
        .finally(function () {
            logger.debug('Closing database connections...');
            return Q.allSettled([storage.closeDatabase(), gmeAuth.unload()])
                .finally(function () {
                    logger.debug('Closed.');
                    if (error) {
                        throw error;
                    }
                });
        });
}
function cleanUp ( options ) { var BlobClient = require ( '../server/middleware/blob/BlobClientWithFSBackend' ) , blobClient , logger , gmeAuth , error , storage ; if ( options && options . env ) { process . env . NODE_ENV = options . env ; } gmeConfig = require ( path . join ( process . cwd ( ) , 'config' ) ) ; webgme . addToRequireJsPaths ( gmeConfig ) ; logger = webgme . Logger . create ( 'clean_up' , gmeConfig . bin . log , false ) ; blobClient = new BlobClient ( gmeConfig , logger ) ; options = options || { } ; return webgme . getGmeAuth ( gmeConfig ) . then ( function ( gmeAuth_ ) { gmeAuth = gmeAuth_ ; storage = webgme . getStorage ( logger , gmeConfig , gmeAuth ) ; return storage . openDatabase ( ) ; } ) . then ( function ( ) { if ( options . input ) { return getInputHashes ( options . input ) ; } else { return getUnusedMetaHashes ( blobClient , gmeAuth . metadataStorage , storage ) ; } } ) . then ( function ( unusedMetaHashes ) { if ( options . del !== true && ! options . input ) { console . log ( 'The following metaDataHashes are unused:' ) ; console . log ( unusedMetaHashes ) ; return null ; } else { return removeBasedOnMetaHashes ( blobClient , unusedMetaHashes ) ; } } ) . then ( function ( removals ) { if ( removals ) { console . log ( 'The following items were removed:' ) ; console . log ( JSON . stringify ( removals , null , 2 ) ) ; } } ) . catch ( function ( err_ ) { error = err_ ; } ) . finally ( function ( ) { logger . debug ( 'Closing database connections...' ) ; return Q . allSettled ( [ storage . closeDatabase ( ) , gmeAuth . unload ( ) ] ) . finally ( function ( ) { logger . debug ( 'Closed.' ) ; if ( error ) { throw error ; } } ) ; } ) ; }
Lists and optionally deletes the unused data from file-system based Blob-storage.

@param {object} [options]
@param {bool} [options.del=false] - If true will do the deletion.
@param {string} [options.env] - If given it will set the NODE_ENV environment variable.
@param {string} [options.input] - Input JSON array file, that contains MetaDataHashes that needs to be removed.
Lists and optionally deletes the unused data from file - system based Blob - storage .