Skip to content

Commit 7c221cc

Browse files
committed
make opend install xpack-win64 work
1 parent ab161c8 commit 7c221cc

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

opend/src/opend.d

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ void downloadXpack(string which) {
420420

421421
string url = "https://github.com/opendlang/opend/releases/download/CI/opend-latest-" ~ which ~ ".tar.xz";
422422
string destination = getXpackPath();
423+
bool done;
423424

424425
void processor() {
425426
TarFileHeader tfh;
@@ -429,20 +430,33 @@ void downloadXpack(string which) {
429430
import std.stdio;
430431
File file;
431432
long currentFileSize;
433+
bool skippingFile;
432434

433435
decompressLzma(
434436
(in ubyte[] chunk) => cast(void) processTar(&tfh, &size, chunk,
435437
(header, isNewFile, fileFinished, data) {
436438
if(isNewFile) {
437-
import std.stdio; writeln("inflating xpack file ", header.filename);
438-
import std.path, std.file;
439-
mkdirRecurse(dirName(buildPath(destination, header.filename)));
440-
file = File(buildPath(destination, header.filename), "wb");
441-
currentFileSize = header.size;
439+
if(header.type == TarFileType.normal)
440+
skippingFile = false;
441+
else
442+
skippingFile = true;
443+
444+
if(!skippingFile) {
445+
import std.stdio; writeln("inflating xpack file ", header.filename);
446+
import std.path, std.file;
447+
mkdirRecurse(dirName(buildPath(destination, header.filename)));
448+
file = File(buildPath(destination, header.filename), "wb");
449+
currentFileSize = header.size;
450+
} else {
451+
}
452+
}
453+
if(!skippingFile)
454+
file.rawWrite(data);
455+
if(fileFinished) {
456+
if(!skippingFile)
457+
file.close();
458+
skippingFile = false;
442459
}
443-
file.rawWrite(data);
444-
if(fileFinished)
445-
file.close();
446460
}),
447461
(ubyte[] buffer) {
448462
try_again:
@@ -458,6 +472,8 @@ void downloadXpack(string which) {
458472
},
459473
tarBuffer[]
460474
);
475+
476+
done = true;
461477
}
462478

463479
auto fiber = new Fiber(&processor, 1 * 1024 * 1024 /* reserve 1 MB stack */);
@@ -468,8 +484,9 @@ void downloadXpack(string which) {
468484
auto http = HTTP(url);
469485
http.onReceive = (ubyte[] data) {
470486
availableData = data;
471-
fiber.call();
472-
return data.length - availableData.length;
487+
if(!done)
488+
fiber.call();
489+
return data.length;
473490
};
474491
http.perform();
475492

0 commit comments

Comments
 (0)