Some cleanup

- Use whateverEmitter.event for the onWhatever methods.
- Add readonly to a bunch of things.
- Remove some redundancy in types.
- Move initializations out of the constructor and into the declarations
  where it was reasonable to do so.
- Disable a few no-any violations.
This commit is contained in:
Asher
2019-02-06 11:53:23 -06:00
parent ddf96077a3
commit 588da0443c
16 changed files with 98 additions and 164 deletions

View File

@@ -1,7 +1,7 @@
import { exec } from "child_process";
import { appendFile } from "fs";
import { promisify } from "util";
import { logger, Logger } from "@coder/logger";
import { logger } from "@coder/logger";
import { escapePath } from "@coder/protocol";
import { NotificationService, INotificationService, ProgressService, IProgressService, IProgress, Severity } from "./fill/notification";
@@ -40,27 +40,20 @@ export class Upload {
private readonly maxParallelUploads = 100;
private readonly readSize = 32000; // ~32kb max while reading in the file.
private readonly packetSize = 32000; // ~32kb max when writing.
private readonly logger: Logger;
private readonly currentlyUploadingFiles: Map<string, File>;
private readonly queueByDirectory: Map<string, IUploadableDirectory>;
private readonly logger = logger.named("Upload");
private readonly currentlyUploadingFiles = new Map<string, File>();
private readonly queueByDirectory = new Map<string, IUploadableDirectory>();
private progress: IProgress | undefined;
private uploadPromise: Promise<string[]> | undefined;
private resolveUploadPromise: (() => void) | undefined;
private finished: number;
private uploadedFilePaths: string[];
private total: number;
private finished = 0;
private uploadedFilePaths = <string[]>[];
private total = 0;
public constructor(
private _notificationService: INotificationService,
private _progressService: IProgressService,
) {
this.logger = logger.named("Upload");
this.currentlyUploadingFiles = new Map();
this.queueByDirectory = new Map();
this.uploadedFilePaths = [];
this.finished = 0;
this.total = 0;
}
) {}
public set notificationService(service: INotificationService) {
this._notificationService = service;