Updated tests. Added a FORMAT flag to make things clearer.
This commit is contained in:
parent
4dc7474fd5
commit
c434385fe4
|
@ -26,8 +26,9 @@ require(["src/filesystem"], function(IDBFS) {
|
|||
if(!error) {
|
||||
console.log("bytes written:", bytes_written);
|
||||
}
|
||||
fd.seek(-bytes_written);
|
||||
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);
|
||||
|
@ -39,11 +40,12 @@ require(["src/filesystem"], function(IDBFS) {
|
|||
});
|
||||
});
|
||||
});
|
||||
}, true);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
}, true);
|
||||
}, IDBFS.FORMAT);
|
||||
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -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);
|
||||
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 fileStore = transaction.objectStore(FILE_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;
|
||||
|
|
Loading…
Reference in New Issue