Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loadBucketMetadata(path: string,
cb: (metadata: BucketMetadata) => void): void {
const { bucket } = this.path.analyze(path);
const params = { Bucket: bucket };
const funcs = async.reflectAll({
acceleration: async.apply(this.getBucketAcceleration.bind(this), params),
acl: async.apply(this.getBucketAcl.bind(this), params),
encryption: async.apply(this.getBucketEncryption.bind(this), params),
logging: async.apply(this.getBucketLogging.bind(this), params),
tagging: async.apply(this.getBucketTagging.bind(this), params),
versioning: async.apply(this.getBucketVersioning.bind(this), params),
website: async.apply(this.getBucketWebsite.bind(this), params)
});
// now load them all in parallel
async.parallelLimit(funcs, config.numParallelOps, (err, data: { value }) => {
// NOTE: we are ignoring errors and only recording metadata actually found
// reason: a bucket with no tags for example errors on the tagging call
// TODO: while developing, log this nicely
console.group(`%cloadBucketMetadata('${bucket}')`, `color: #004d40`);
const metadata = Object.keys(funcs).reduce((acc, key) => {
acc[key] = data[key].value || { };
loadFileMetadata(path: string,
cb: (metadata: FileMetadata) => void): void {
const { bucket, prefix, version } = this.path.analyze(path);
const params = {
Bucket: bucket,
Key: prefix,
VersionId: version
};
const funcs = async.reflectAll({
acl: async.apply(this.getObjectAcl.bind(this), params),
head: async.apply(this.getObjectHead.bind(this), params),
tagging: async.apply(this.getObjectTagging.bind(this), params)
});
// now load them all in parallel
async.parallelLimit(funcs, config.numParallelOps, (err, data: { value }) => {
// NOTE: we are ignoring errors and only recording metadata actually found
// reason: a file with no tags for example errors on the tagging call
// TODO: while developing, log this nicely
console.group(`%cloadFileMetadata('${path}')`, `color: #006064`);
const metadata = Object.keys(funcs).reduce((acc, key) => {
acc[key] = data[key].value || { };
console.log(`%c${key} %c${JSON.stringify(acc[key])}`, 'color: black', 'color: grey');
return acc;
}, { } as FileMetadata);
console.groupEnd();
deleteItems(tableName: string,
keys: DDB.Key[],
cb: Function): void {
// build a list of delete functions
const funcs = async.reflectAll(keys.map(key => {
const params = {
Key: key,
TableName: tableName
};
return async.apply(this.deleteItem.bind(this), params);
}));
// now delete them, one at a time
async.series(funcs, (err, data) => cb());
}