Handle empty filesystem correctly

This commit is contained in:
copy 2015-03-07 01:24:38 +01:00
parent bd0c20af0a
commit 633013648e
2 changed files with 26 additions and 14 deletions

View file

@ -214,6 +214,11 @@ function ReadTag(buffer, offset) {
FS.prototype.OnJSONLoaded = function(fs) FS.prototype.OnJSONLoaded = function(fs)
{ {
if(DEBUG)
{
console.assert(fs, "Invalid fs passed to OnJSONLoaded");
}
//console.time("parse"); //console.time("parse");
var fsroot = JSON.parse(fs)["fsroot"]; var fsroot = JSON.parse(fs)["fsroot"];
//console.timeEnd("parse"); //console.timeEnd("parse");
@ -344,19 +349,26 @@ FS.prototype.LoadFile = function(idx) {
// return; // return;
//} //}
LoadBinaryResource(this.baseurl + this.GetFullPath(inode.fid), if(this.baseurl)
function(buffer){ {
var data = this.inodedata[idx] = new Uint8Array(buffer); LoadBinaryResource(this.baseurl + this.GetFullPath(inode.fid),
inode.size = data.length; // correct size if the previous was wrong. function(buffer){
inode.status = STATUS_OK; var data = this.inodedata[idx] = new Uint8Array(buffer);
//if (inode.name == "rcS") { inode.size = data.length; // correct size if the previous was wrong.
// this.AppendDateHack(idx); inode.status = STATUS_OK;
//} //if (inode.name == "rcS") {
this.filesinloadingqueue--; // this.AppendDateHack(idx);
this.HandleEvent(idx); //}
}.bind(this), this.filesinloadingqueue--;
function(error){throw error;}); this.HandleEvent(idx);
}.bind(this),
function(error){throw error;});
}
else
{
// If baseurl is not set, we started with an empty filesystem. No files
// can be loaded
}
} }
// ----------------------------------------------------- // -----------------------------------------------------

View file

@ -345,7 +345,7 @@ function V86Starter(options)
setTimeout(function() setTimeout(function()
{ {
if(settings.fs9p) if(settings.fs9p && settings.fs9p_json)
{ {
settings.fs9p.OnJSONLoaded(settings.fs9p_json); settings.fs9p.OnJSONLoaded(settings.fs9p_json);
} }