added /config endpoint, use fewer globals (#1172)

* added /config endpoint, use fewer globals

* fixed integration tests
This commit is contained in:
Danny Coates 2019-02-26 10:39:50 -08:00 committed by GitHub
parent 8df400a676
commit 1c44d1d0f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 92 additions and 80 deletions

View file

@ -1,4 +1,3 @@
/* global LIMITS DEFAULTS */
import { blobStream, concatStream } from './streams';
function isDupe(newFile, array) {
@ -15,9 +14,10 @@ function isDupe(newFile, array) {
}
export default class Archive {
constructor(files = []) {
constructor(files = [], defaultTimeLimit = 86400) {
this.files = Array.from(files);
this.timeLimit = DEFAULTS.EXPIRE_SECONDS;
this.defaultTimeLimit = defaultTimeLimit;
this.timeLimit = defaultTimeLimit;
this.dlimit = 1;
this.password = null;
}
@ -52,8 +52,8 @@ export default class Archive {
return concatStream(this.files.map(file => blobStream(file)));
}
addFiles(files, maxSize) {
if (this.files.length + files.length > LIMITS.MAX_FILES_PER_ARCHIVE) {
addFiles(files, maxSize, maxFiles) {
if (this.files.length + files.length > maxFiles) {
throw new Error('tooManyFiles');
}
const newFiles = files.filter(
@ -77,7 +77,7 @@ export default class Archive {
clear() {
this.files = [];
this.dlimit = 1;
this.timeLimit = DEFAULTS.EXPIRE_SECONDS;
this.timeLimit = this.defaultTimeLimit;
this.password = null;
}
}