Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
updateFileMetadata(path: string,
metadata: FileMetadata,
cb?: () => void): void {
const { bucket, prefix, version } = this.path.analyze(path);
const params = {
Bucket: bucket,
Key: prefix,
VersionId: version
};
const funcs = [
async.apply(this.putObjectAcl.bind(this), params, metadata.acl),
async.apply(this.putObjectHead.bind(this), params, path, metadata.head),
async.apply(this.putObjectTagging.bind(this), params, metadata.tagging)
];
// now update them all in parallel
async.parallelLimit(funcs, config.numParallelOps, (err, results: any) => {
// TODO: we'd like the watcher to see this automagically
this.watcher.touch(path);
if (err)
this.store.dispatch(new Message({ level: 'error', text: err.toString() }));
else {
// TODO: while developing, log this nicely
console.group(`%cupdateFileMetadata('${bucket}')`, `color: #1b5e20`);
Object.keys(metadata).forEach(key => {
console.log(`%c${key} %c${JSON.stringify(metadata[key])}`, 'color: black', 'color: grey');
});
console.groupEnd();
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 || { };
console.log(`%c${key} %c${JSON.stringify(acc[key])}`, 'color: black', 'color: grey');
return acc;
updateFileMetadata(path: string,
metadata: FileMetadata,
cb?: () => void): void {
const { bucket, prefix, version } = this.path.analyze(path);
const params = {
Bucket: bucket,
Key: prefix,
VersionId: version
};
const funcs = [
async.apply(this.putObjectAcl.bind(this), params, metadata.acl),
async.apply(this.putObjectHead.bind(this), params, path, metadata.head),
async.apply(this.putObjectTagging.bind(this), params, metadata.tagging)
];
// now update them all in parallel
async.parallelLimit(funcs, config.numParallelOps, (err, results: any) => {
// TODO: we'd like the watcher to see this automagically
this.watcher.touch(path);
if (err)
this.store.dispatch(new Message({ level: 'error', text: err.toString() }));
else {
// TODO: while developing, log this nicely
console.group(`%cupdateFileMetadata('${bucket}')`, `color: #1b5e20`);
Object.keys(metadata).forEach(key => {
console.log(`%c${key} %c${JSON.stringify(metadata[key])}`, 'color: black', 'color: grey');
});
console.groupEnd();
if (cb) cb();
updateBucketMetadata(path: string,
metadata: BucketMetadata,
cb?: () => void): void {
const { bucket } = this.path.analyze(path);
const params = { Bucket: bucket };
const funcs = [
async.apply(this.putBucketAcceleration.bind(this), params, metadata.acceleration),
async.apply(this.putBucketAcl.bind(this), params, metadata.acl),
async.apply(this.putBucketEncryption.bind(this), params, metadata.encryption),
async.apply(this.putBucketLogging.bind(this), params, metadata.logging),
async.apply(this.putBucketTagging.bind(this), params, metadata.tagging),
async.apply(this.putBucketVersioning.bind(this), params, metadata.versioning),
async.apply(this.putBucketWebsite.bind(this), params, metadata.website)
];
// now update them all in parallel
async.parallelLimit(funcs, config.numParallelOps, (err, results: any) => {
// TODO: we'd like the watcher to see this automagically
this.watcher.touch(path);
if (err)
this.store.dispatch(new Message({ level: 'error', text: err.toString() }));
else {
// TODO: while developing, log this nicely
console.group(`%cupdateBucketMetadata('${bucket}')`, `color: #0d47a1`);
Object.keys(metadata).forEach(key => {
console.log(`%c${key} %c${JSON.stringify(metadata[key])}`, 'color: black', 'color: grey');
});
console.groupEnd();
if (cb) cb();
}
updateBucketMetadata(path: string,
metadata: BucketMetadata,
cb?: () => void): void {
const { bucket } = this.path.analyze(path);
const params = { Bucket: bucket };
const funcs = [
async.apply(this.putBucketAcceleration.bind(this), params, metadata.acceleration),
async.apply(this.putBucketAcl.bind(this), params, metadata.acl),
async.apply(this.putBucketEncryption.bind(this), params, metadata.encryption),
async.apply(this.putBucketLogging.bind(this), params, metadata.logging),
async.apply(this.putBucketTagging.bind(this), params, metadata.tagging),
async.apply(this.putBucketVersioning.bind(this), params, metadata.versioning),
async.apply(this.putBucketWebsite.bind(this), params, metadata.website)
];
// now update them all in parallel
async.parallelLimit(funcs, config.numParallelOps, (err, results: any) => {
// TODO: we'd like the watcher to see this automagically
this.watcher.touch(path);
if (err)
this.store.dispatch(new Message({ level: 'error', text: err.toString() }));
else {
// TODO: while developing, log this nicely
console.group(`%cupdateBucketMetadata('${bucket}')`, `color: #0d47a1`);
Object.keys(metadata).forEach(key => {
updateBucketMetadata(path: string,
metadata: BucketMetadata,
cb?: () => void): void {
const { bucket } = this.path.analyze(path);
const params = { Bucket: bucket };
const funcs = [
async.apply(this.putBucketAcceleration.bind(this), params, metadata.acceleration),
async.apply(this.putBucketAcl.bind(this), params, metadata.acl),
async.apply(this.putBucketEncryption.bind(this), params, metadata.encryption),
async.apply(this.putBucketLogging.bind(this), params, metadata.logging),
async.apply(this.putBucketTagging.bind(this), params, metadata.tagging),
async.apply(this.putBucketVersioning.bind(this), params, metadata.versioning),
async.apply(this.putBucketWebsite.bind(this), params, metadata.website)
];
// now update them all in parallel
async.parallelLimit(funcs, config.numParallelOps, (err, results: any) => {
// TODO: we'd like the watcher to see this automagically
this.watcher.touch(path);
if (err)
this.store.dispatch(new Message({ level: 'error', text: err.toString() }));
else {
// TODO: while developing, log this nicely
console.group(`%cupdateBucketMetadata('${bucket}')`, `color: #0d47a1`);
Object.keys(metadata).forEach(key => {
console.log(`%c${key} %c${JSON.stringify(metadata[key])}`, 'color: black', 'color: grey');
});
console.groupEnd();
if (cb) cb();
updateBucketMetadata(path: string,
metadata: BucketMetadata,
cb?: () => void): void {
const { bucket } = this.path.analyze(path);
const params = { Bucket: bucket };
const funcs = [
async.apply(this.putBucketAcceleration.bind(this), params, metadata.acceleration),
async.apply(this.putBucketAcl.bind(this), params, metadata.acl),
async.apply(this.putBucketEncryption.bind(this), params, metadata.encryption),
async.apply(this.putBucketLogging.bind(this), params, metadata.logging),
async.apply(this.putBucketTagging.bind(this), params, metadata.tagging),
async.apply(this.putBucketVersioning.bind(this), params, metadata.versioning),
async.apply(this.putBucketWebsite.bind(this), params, metadata.website)
];
// now update them all in parallel
async.parallelLimit(funcs, config.numParallelOps, (err, results: any) => {
// TODO: we'd like the watcher to see this automagically
this.watcher.touch(path);
if (err)
this.store.dispatch(new Message({ level: 'error', text: err.toString() }));
else {
// TODO: while developing, log this nicely
console.group(`%cupdateBucketMetadata('${bucket}')`, `color: #0d47a1`);
Object.keys(metadata).forEach(key => {
console.log(`%c${key} %c${JSON.stringify(metadata[key])}`, 'color: black', 'color: grey');
});
console.groupEnd();
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 || { };
console.log(`%c${key} %c${JSON.stringify(acc[key])}`, 'color: black', 'color: grey');
return acc;
}, { } as BucketMetadata);
updateBucketMetadata(path: string,
metadata: BucketMetadata,
cb?: () => void): void {
const { bucket } = this.path.analyze(path);
const params = { Bucket: bucket };
const funcs = [
async.apply(this.putBucketAcceleration.bind(this), params, metadata.acceleration),
async.apply(this.putBucketAcl.bind(this), params, metadata.acl),
async.apply(this.putBucketEncryption.bind(this), params, metadata.encryption),
async.apply(this.putBucketLogging.bind(this), params, metadata.logging),
async.apply(this.putBucketTagging.bind(this), params, metadata.tagging),
async.apply(this.putBucketVersioning.bind(this), params, metadata.versioning),
async.apply(this.putBucketWebsite.bind(this), params, metadata.website)
];
// now update them all in parallel
async.parallelLimit(funcs, config.numParallelOps, (err, results: any) => {
// TODO: we'd like the watcher to see this automagically
this.watcher.touch(path);
if (err)
this.store.dispatch(new Message({ level: 'error', text: err.toString() }));
else {
// TODO: while developing, log this nicely
console.group(`%cupdateBucketMetadata('${bucket}')`, `color: #0d47a1`);
Object.keys(metadata).forEach(key => {
console.log(`%c${key} %c${JSON.stringify(metadata[key])}`, 'color: black', 'color: grey');
.reduce((acc, params) => {
acc.push(async.apply(this.s3.deleteObject, params));
return acc;
}, []);
// now delete them all in parallel