steam-manifest-tools 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/include/lib.js +37 -23
- package/package.json +5 -1
package/include/lib.js
CHANGED
|
@@ -119,9 +119,11 @@ module.exports = {
|
|
|
119
119
|
if (file.flags & 64) {
|
|
120
120
|
continue;
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
const filename = file.filename.replace(/\\/g, "/");
|
|
123
|
+
if (fs.existsSync(path.join(installDir, filename))) {
|
|
124
|
+
const readSteam = await fsPromises.open(path.join(installDir, filename), "r");
|
|
124
125
|
let chunk_i = 0;
|
|
126
|
+
const writePromises = [];
|
|
125
127
|
for (const chunk of file.chunks) {
|
|
126
128
|
if (!fs.existsSync(`depot/${manifest.depot_id}/chunk/${chunk.sha}`)) {
|
|
127
129
|
let chunkBuf = Buffer.alloc(chunk.cb_original);
|
|
@@ -132,14 +134,18 @@ module.exports = {
|
|
|
132
134
|
if (sha1(chunkBuf) == chunk.sha) {
|
|
133
135
|
chunkBuf = compress(chunkBuf);
|
|
134
136
|
chunkBuf = SteamCrypto.symmetricEncrypt(chunkBuf, depotKey);
|
|
135
|
-
|
|
137
|
+
const writePromise = fsPromises.writeFile(`depot/${manifest.depot_id}/chunk/${chunk.sha}`, chunkBuf);
|
|
136
138
|
if (onProgress) {
|
|
137
|
-
|
|
139
|
+
writePromise.then(() => {
|
|
140
|
+
onProgress(filename, file_i, manifest.files.length, chunk_i++, file.chunks.length)
|
|
141
|
+
});
|
|
138
142
|
}
|
|
143
|
+
writePromises.push(writePromise);
|
|
139
144
|
}
|
|
140
145
|
}
|
|
141
146
|
}
|
|
142
147
|
await readSteam.close();
|
|
148
|
+
await Promise.all(writePromises);
|
|
143
149
|
}
|
|
144
150
|
++file_i;
|
|
145
151
|
}
|
|
@@ -164,8 +170,9 @@ module.exports = {
|
|
|
164
170
|
resolve();
|
|
165
171
|
}
|
|
166
172
|
let /*host_i = 0,*/ running = 0;
|
|
173
|
+
const concurrency = hosts.length == 1 ? 4 : (hosts.length * 2);
|
|
167
174
|
const loop = () => {
|
|
168
|
-
while (running <
|
|
175
|
+
while (running < concurrency) {
|
|
169
176
|
const path = Object.keys(toDownload)[0];
|
|
170
177
|
if (!path) {
|
|
171
178
|
break;
|
|
@@ -209,36 +216,43 @@ module.exports = {
|
|
|
209
216
|
ContentManifest.decryptFilenames(manifest, depotKey);
|
|
210
217
|
installDir ??= `install/${manifest.depot_id}/${manifest.gid_manifest}`;
|
|
211
218
|
fs.mkdirSync(installDir, { recursive: true });
|
|
219
|
+
const promises = [];
|
|
212
220
|
for (const file of manifest.files) {
|
|
213
221
|
if (file.flags & 64) {
|
|
214
222
|
continue;
|
|
215
223
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
224
|
+
promises.push((async () => {
|
|
225
|
+
const filename = file.filename.replace(/\\/g, "/");
|
|
226
|
+
const exists = fs.existsSync(path.join(installDir, filename));
|
|
227
|
+
if (!exists || await sha1file(path.join(installDir, filename)) != file.sha_content) {
|
|
228
|
+
for (const chunk of file.chunks) {
|
|
229
|
+
chunk.offset = parseInt(chunk.offset);
|
|
230
|
+
}
|
|
231
|
+
file.chunks.sort((a, b) => a.offset - b.offset);
|
|
222
232
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
onFileWritten(file.filename, exists);
|
|
233
|
+
await fsPromises.mkdir(path.dirname(path.join(installDir, filename)), { recursive: true });
|
|
234
|
+
const writeStream = await fsPromises.open(path.join(installDir, filename), "w");
|
|
235
|
+
for (const chunk of file.chunks) {
|
|
236
|
+
await writeStream.write(await getChunk(manifest.depot_id, depotKey, chunk.sha));
|
|
237
|
+
}
|
|
238
|
+
await writeStream.close();
|
|
239
|
+
if (onFileWritten) {
|
|
240
|
+
onFileWritten(filename, exists);
|
|
241
|
+
}
|
|
233
242
|
}
|
|
234
|
-
}
|
|
243
|
+
})());
|
|
235
244
|
}
|
|
245
|
+
await Promise.all(promises);
|
|
236
246
|
},
|
|
237
247
|
verifyChunks: async (depotId, depotKey, onDeletedFile) => {
|
|
238
248
|
const files = await getFiles(`depot/${depotId}/chunk`);
|
|
239
|
-
|
|
249
|
+
let promises = [];
|
|
240
250
|
for (const file of files) {
|
|
241
251
|
const hash = file.substr(file.length - 40);
|
|
252
|
+
if (promises.length > 40) {
|
|
253
|
+
await Promise.all(promises);
|
|
254
|
+
promises = [];
|
|
255
|
+
}
|
|
242
256
|
promises.push(getFileContents(file).then(async data => {
|
|
243
257
|
try {
|
|
244
258
|
data = SteamCrypto.symmetricDecrypt(data, depotKey);
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "steam-manifest-tools",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"main": "include/lib.js",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/Sainan/steam-manifest-tools.git"
|
|
8
|
+
},
|
|
5
9
|
"dependencies": {
|
|
6
10
|
"@doctormckay/steam-crypto": "^1.2.0",
|
|
7
11
|
"adm-zip": "^0.5.16",
|