mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2026-01-15 12:15:02 +00:00
Fallback if we get a failed 206 (maybe)
This commit is contained in:
@@ -484,6 +484,9 @@ function syncGet(url, offset, length) {
|
||||
}
|
||||
}
|
||||
};
|
||||
req.onerror = function (event) {
|
||||
err = event;
|
||||
};
|
||||
req.send();
|
||||
if (err) {
|
||||
throw err;
|
||||
@@ -559,18 +562,7 @@ function buildFileSystem(writableStorage, isDropBox) {
|
||||
buildCDROMFileSystem(Buffer, function (cdromfs) {
|
||||
buildExtraFileSystems(Buffer, function (extraFSs) {
|
||||
buildAppFileSystems(function (homeAdapter) {
|
||||
if (Config.useRangeRequests == ONDEMAND_ROOT) {
|
||||
buildRemoteZipFile(Config.rootZipFile, function callback(zipfs) {
|
||||
buildBrowserFileSystem(
|
||||
writableStorage,
|
||||
isDropBox,
|
||||
homeAdapter,
|
||||
extraFSs,
|
||||
zipfs,
|
||||
cdromfs
|
||||
);
|
||||
});
|
||||
} else {
|
||||
const loadWholeRoot = function () {
|
||||
var rootListingObject = {};
|
||||
rootListingObject[Config.rootZipFile] = null;
|
||||
BrowserFS.FileSystem.XmlHttpRequest.Create(
|
||||
@@ -610,6 +602,24 @@ function buildFileSystem(writableStorage, isDropBox) {
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
if (Config.useRangeRequests === ONDEMAND_ROOT) {
|
||||
buildRemoteZipFile(Config.rootZipFile, function callback(zipfs) {
|
||||
if (zipfs) {
|
||||
buildBrowserFileSystem(
|
||||
writableStorage,
|
||||
isDropBox,
|
||||
homeAdapter,
|
||||
extraFSs,
|
||||
zipfs,
|
||||
cdromfs
|
||||
);
|
||||
} else {
|
||||
loadWholeRoot();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
loadWholeRoot();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -618,28 +628,37 @@ function buildFileSystem(writableStorage, isDropBox) {
|
||||
function buildRemoteZipFile(zipFilename, zipFileCallback) {
|
||||
var Buffer = BrowserFS.BFSRequire("buffer").Buffer;
|
||||
getFileSize(zipFilename).then(function (fileSizeAsString) {
|
||||
let fileSizeAsInt = Number(fileSizeAsString);
|
||||
let blockSize = fileSizeAsInt > 100000 ? 100000 : fileSizeAsInt - 22;
|
||||
let lastPartOfFile = syncGet(
|
||||
zipFilename,
|
||||
fileSizeAsInt - blockSize,
|
||||
blockSize
|
||||
);
|
||||
let centralOffset = getCentralOffset(new Uint8Array(lastPartOfFile));
|
||||
let remainingLength = fileSizeAsInt - centralOffset;
|
||||
let contents = syncGet(zipFilename, centralOffset, remainingLength);
|
||||
BrowserFS.FileSystem.ZipFS.Create(
|
||||
{
|
||||
name: Config.locateRootBaseUrl + zipFilename,
|
||||
zipData: new Buffer(contents),
|
||||
},
|
||||
function (e3, zipfs) {
|
||||
if (e3) {
|
||||
logAndExit(e3);
|
||||
let contents = null;
|
||||
try {
|
||||
let fileSizeAsInt = Number(fileSizeAsString);
|
||||
let blockSize = fileSizeAsInt > 100000 ? 100000 : fileSizeAsInt - 22;
|
||||
let lastPartOfFile = syncGet(
|
||||
zipFilename,
|
||||
fileSizeAsInt - blockSize,
|
||||
blockSize
|
||||
);
|
||||
let centralOffset = getCentralOffset(new Uint8Array(lastPartOfFile));
|
||||
let remainingLength = fileSizeAsInt - centralOffset;
|
||||
contents = syncGet(zipFilename, centralOffset, remainingLength);
|
||||
} catch {
|
||||
// Ignore failure to get zip on demand.
|
||||
}
|
||||
if (contents) {
|
||||
BrowserFS.FileSystem.ZipFS.Create(
|
||||
{
|
||||
name: Config.locateRootBaseUrl + zipFilename,
|
||||
zipData: new Buffer(contents),
|
||||
},
|
||||
function (e3, zipfs) {
|
||||
if (e3) {
|
||||
logAndExit(e3);
|
||||
}
|
||||
zipFileCallback(zipfs);
|
||||
}
|
||||
zipFileCallback(zipfs);
|
||||
}
|
||||
);
|
||||
);
|
||||
} else {
|
||||
zipFileCallback();
|
||||
}
|
||||
});
|
||||
}
|
||||
function getBase64Data(base64Data) {
|
||||
|
||||
Reference in New Issue
Block a user