Updated tests. Added a FORMAT flag to make things clearer.

This commit is contained in:
Alan Kligman 2012-10-13 11:06:17 -04:00
parent 4dc7474fd5
commit c434385fe4
2 changed files with 33 additions and 20 deletions

View File

@ -26,24 +26,26 @@ require(["src/filesystem"], function(IDBFS) {
if(!error) {
console.log("bytes written:", bytes_written);
}
fd.seek(-bytes_written);
var readBuffer = new Uint8Array(8);
fd.read(readBuffer, function(error, bytes_read, buffer) {
if(!error) {
console.log("bytes read:", bytes_read);
console.log("buffer:", buffer);
}
fs.close(fd, function(error) {
fs.unlink("/tmp/0", function(error) {
fs.dump(document.getElementById("stdout"));
fs.dump(document.getElementById("stdout"), function() {
var readBuffer = new Uint8Array(8);
fd.seek(-bytes_written);
fd.read(readBuffer, function(error, bytes_read, buffer) {
if(!error) {
console.log("bytes read:", bytes_read);
console.log("buffer:", buffer);
}
fs.close(fd, function(error) {
fs.unlink("/tmp/0", function(error) {
fs.dump(document.getElementById("stdout"));
});
});
});
});
}, true);
});
});
});
}, true);
}, IDBFS.FORMAT);
});
</script>

View File

@ -486,11 +486,13 @@ define(function(require) {
this.api = api;
// DEBUG
function dump(element) {
element.innerHTML = "Metadata://<br>";
var transaction = db.transaction([METADATA_STORE_NAME, FILE_STORE_NAME], IDB_RO);
var metaStore = transaction.objectStore(METADATA_STORE_NAME);
var fileStore = transaction.objectStore(FILE_STORE_NAME);
function dump(element, callback, clear) {
if(clear) {
element.innerHTML = "";
}
element.innerHTML += "Metadata://<br>";
var transaction = db.transaction([METADATA_STORE_NAME], IDB_RO);
var metaStore = transaction.objectStore(METADATA_STORE_NAME);
var metaRequest = metaStore.openCursor();
metaRequest.onsuccess = function(e) {
var metaCursor = e.target.result;
@ -499,12 +501,19 @@ define(function(require) {
metaCursor.continue();
} else {
element.innerHTML += "Files://<br>"
fileRequest = fileStore.openCursor();
transaction = db.transaction([FILE_STORE_NAME], IDB_RO);
var fileStore = transaction.objectStore(FILE_STORE_NAME);
var fileRequest = fileStore.openCursor();
fileRequest.onsuccess = function(e) {
var fileCursor = e.target.result;
if(fileCursor) {
element.innerHTML += JSON.stringify(fileCursor.key) + "<br>";
fileCursor.continue();
} else {
element.innerHTML += "-----------------<br>";
if(callback && "function" === typeof callback) {
callback.call();
}
}
}
}
@ -515,7 +524,7 @@ define(function(require) {
function mount(name, callback, optFormat) {
debug.info("mount -->");
optFormat = (undefined === optFormat) ? false : optFormat;
optFormat = (IDBFS.FORMAT === optFormat) ? true : false;
var onerror = genericIDBErrorHandler("mount", callback);
var openRequest = indexedDB.open(name);
openRequest.onupgradeneeded = function(e) {
@ -574,7 +583,9 @@ define(function(require) {
var IDBFS = {
mount: mount,
umount: undefined,
path: path
path: path,
FORMAT: "IDBFS_FORMAT"
};
return IDBFS;