Skip to content

Commit

Permalink
Merge pull request #18 from 9KwHCUDP/master
Browse files Browse the repository at this point in the history
Updates node-steam-user dep to from 3.x to 4.x
  • Loading branch information
Step7750 authored Sep 1, 2019
2 parents 3948430 + 114f561 commit 578e3f8
Show file tree
Hide file tree
Showing 3 changed files with 253 additions and 297 deletions.
20 changes: 7 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CSGOCdn extends EventEmitter {
}

get steamReady() {
return this.user.client.connected;
return !!this.user.steamID;
}

get phase() {
Expand Down Expand Up @@ -152,7 +152,7 @@ class CSGOCdn extends EventEmitter {
getLatestManifestId() {
this.log.debug('Obtaining latest manifest ID');
return this.getProductInfo().then(([apps, packages, unknownApps, unknownPackages]) => {
const csgo = apps['730'].appinfo;
const csgo = packages['730'].appinfo;
const commonDepot = csgo.depots['731'];

return commonDepot.manifests.public;
Expand Down Expand Up @@ -286,7 +286,7 @@ class CSGOCdn extends EventEmitter {
continue;
}

const promise = this.user.downloadFileAsync(730, 731, file, `${this.config.directory}/${name}`);
const promise = this.user.downloadFile(730, 731, file, `${this.config.directory}/${name}`);
promises.push(promise);
}

Expand Down Expand Up @@ -365,18 +365,12 @@ class CSGOCdn extends EventEmitter {

this.log.info(`${status} Downloading ${fileName} - ${bytesToMB(file.size)} MB`);

const promise = new Promise((resolve, reject) => {
const ee = this.user.downloadFile(730, 731, file, filePath, () => {
resolve();
});

ee.on('progress', (bytesDownloaded, totalSize) => {
this.log.info(`${status} ${(bytesDownloaded*100/totalSize).toFixed(2)}% - ${bytesToMB(bytesDownloaded)}/${bytesToMB(totalSize)} MB`);
});
await this.user.downloadFile(730, 731, file, filePath, (none, { type, bytesDownloaded, totalSizeBytes }) => {
if (type === 'progress') {
this.log.info(`${status} ${(bytesDownloaded*100/totalSizeBytes).toFixed(2)}% - ${bytesToMB(bytesDownloaded)}/${bytesToMB(totalSizeBytes)} MB`);
}
});

await promise;

this.log.info(`${status} Downloaded ${fileName}`);
}
}
Expand Down
Loading

0 comments on commit 578e3f8

Please sign in to comment.