lib/metadata/bucketfile/backend.js
/**
     *  This complex function deals with different extensions of bucket listing:
     *  Delimiter based search or MPU based search.
     *  @param {String} bucketName - The name of the bucket to list
     *  @param {Object} params - The params to search
     *  @param {Object} log - The logger object
     *  @param {function} cb - Callback when done
     *  @return {undefined}
     */
This complex function deals with different extensions of bucket listing:
Delimiter based search or MPU based search.
This complex function deals with different extensions of bucket listing : Delimiter based search or MPU based search .
internalListObject(bucketName, params, log, cb) {
        const requestParams = {};
        let Ext;
        const extParams = {};
        if (params.listingType === 'multipartuploads') {
            Ext = arsenal.algorithms.list.MPU;
            this.addExtensionParam('queryPrefixLength', params, extParams);
            this.addExtensionParam('splitter', params, extParams);
            if (params.keyMarker) {
                requestParams.gt = `overview${params.splitter}` +
                    `${params.keyMarker}${params.splitter}`;
                if (params.uploadIdMarker) {
                    requestParams.gt += `${params.uploadIdMarker}`;
                }
                requestParams.gt = this._setCharAt(requestParams.gt);
            }
        } else {
            Ext = arsenal.algorithms.list.Delimiter;
            if (params.marker) {
                requestParams.gt = params.marker;
                this.addExtensionParam('gt', requestParams, extParams);
            }
        }
        this.addExtensionParam('delimiter', params, extParams);
        this.addExtensionParam('maxKeys', params, extParams);
        if (params.prefix) {
            requestParams.start = params.prefix;
            requestParams.lt = this._setCharAt(params.prefix);
            this.addExtensionParam('start', requestParams, extParams);
        }
        const extension = new Ext(extParams, log);
        this.loadDBIfExists(bucketName, log, (err, db) => {
            if (err) {
                return cb(err);
            }
            let cbDone = false;
            const stream = db.createReadStream(requestParams);
            stream
                .on('data', e => {
                    if (extension.filter(e) === false) {
                        stream.emit('end');
                        stream.destroy();
                    }
                })
                .on('error', err => {
                    if (!cbDone) {
                        this.unRef();
                        cbDone = true;
                        log.error('error listing objects',
                                  { error: err });
                        cb(errors.InternalError);
                    }
                })
                .on('end', () => {
                    if (!cbDone) {
                        this.unRef();
                        cbDone = true;
                        const data = extension.result();
                        cb(null, data);
                    }
                });
            return undefined;
        });
    }
internalListObject ( bucketName , params , log , cb ) { const requestParams = { } ; let Ext ; const extParams = { } ; if ( params . listingType === 'multipartuploads' ) { Ext = arsenal . algorithms . list . MPU ; this . addExtensionParam ( 'queryPrefixLength' , params , extParams ) ; this . addExtensionParam ( 'splitter' , params , extParams ) ; if ( params . keyMarker ) { requestParams . gt = ` ${ params . splitter } ` + ` ${ params . keyMarker } ${ params . splitter } ` ; if ( params . uploadIdMarker ) { requestParams . gt += ` ${ params . uploadIdMarker } ` ; } requestParams . gt = this . _setCharAt ( requestParams . gt ) ; } } else { Ext = arsenal . algorithms . list . Delimiter ; if ( params . marker ) { requestParams . gt = params . marker ; this . addExtensionParam ( 'gt' , requestParams , extParams ) ; } } this . addExtensionParam ( 'delimiter' , params , extParams ) ; this . addExtensionParam ( 'maxKeys' , params , extParams ) ; if ( params . prefix ) { requestParams . start = params . prefix ; requestParams . lt = this . _setCharAt ( params . prefix ) ; this . addExtensionParam ( 'start' , requestParams , extParams ) ; } const extension = new Ext ( extParams , log ) ; this . loadDBIfExists ( bucketName , log , ( err , db ) => { if ( err ) { return cb ( err ) ; } let cbDone = false ; const stream = db . createReadStream ( requestParams ) ; stream . on ( 'data' , e => { if ( extension . filter ( e ) === false ) { stream . emit ( 'end' ) ; stream . destroy ( ) ; } } ) . on ( 'error' , err => { if ( ! cbDone ) { this . unRef ( ) ; cbDone = true ; log . error ( 'error listing objects' , { error : err } ) ; cb ( errors . InternalError ) ; } } ) . on ( 'end' , ( ) => { if ( ! cbDone ) { this . unRef ( ) ; cbDone = true ; const data = extension . result ( ) ; cb ( null , data ) ; } } ) ; return undefined ; } ) ; }
This complex function deals with different extensions of bucket listing:
  Delimiter based search or MPU based search.
This complex function deals with different extensions of bucket listing : Delimiter based search or MPU based search .
// multipart upload listing // advance so that lower bound does not include the supplied // markers