Commit c8628f06 authored by Boris Kocherov's avatar Boris Kocherov

ZipFileStorage: add capacity list

parent 7f72c38a
......@@ -139,6 +139,26 @@ for(d=1;d<=W;d++)f[d]=g=g+c[d-1]<<1;for(e=0;e<=b;e++){var h=a[2*e+1];0!==h&&(a[2
});
};
ZipFileStorage.prototype.hasCapacity = function (name) {
return (name === "list");
};
ZipFileStorage.prototype.buildQuery = function () {
return loadZip(this)
.push(function (zip) {
var dirname,
dir_list = [{id: '/', value: {}}];
for (dirname in zip.files) {
if (zip.files.hasOwnProperty(dirname)) {
if (zip.files[dirname].dir) {
dir_list.push({id: '/' + dirname, value: {}});
}
}
}
return dir_list;
});
};
ZipFileStorage.prototype.allAttachments = function (id) {
id = restrictDocumentId(id);
return loadZip(this)
......
......@@ -125,6 +125,26 @@
});
};
ZipFileStorage.prototype.hasCapacity = function (name) {
return (name === "list");
};
ZipFileStorage.prototype.buildQuery = function () {
return loadZip(this)
.push(function (zip) {
var dirname,
dir_list = [{id: '/', value: {}}];
for (dirname in zip.files) {
if (zip.files.hasOwnProperty(dirname)) {
if (zip.files[dirname].dir) {
dir_list.push({id: '/' + dirname, value: {}});
}
}
}
return dir_list;
});
};
ZipFileStorage.prototype.allAttachments = function (id) {
id = restrictDocumentId(id);
return loadZip(this)
......
......@@ -16,7 +16,7 @@
cd zipfile ; zip -r - * | base64 -w 40)
|sed 's#$#",#' | sed 's#^#"#' ; echo ']')
zipfile contents:
/getid/
/get1/
/id1/
/id2/
/id2/attachment1 -- "foo\nbaré\n"
......@@ -877,4 +877,42 @@
});
});
/////////////////////////////////////////////////////////////////
// zipFileStorage.allDocs
/////////////////////////////////////////////////////////////////
module("zipFileStorage.allDocs", {
setup: function () {
this.jio = jIO.createJIO({
type: "zipfile",
file: zipfile
});
}
});
test("get all docs", function () {
var object_result = {
"data": {
"rows": [
{"id": "/", "value": {}},
{"id": "/get1/", "value": {}},
{"id": "/id1/", "value": {}},
{"id": "/id2/", "value": {}}
],
"total_rows": 4
}
};
stop();
expect(1);
this.jio.allDocs()
.then(function (res) {
deepEqual(res, object_result);
})
.fail(function (error) {
ok(false, error);
})
.always(function () {
start();
});
});
}(jIO, QUnit, Blob, Uint8Array));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment