Commit 015fba85 authored by Boris Kocherov's avatar Boris Kocherov

ZipFileStorage: code improvements

parent 53a8f3cb
...@@ -22,20 +22,16 @@ ...@@ -22,20 +22,16 @@
//} //}
function loadZip(storage) { function loadZip(storage) {
var queue;
if (!storage._error) { if (!storage._error) {
if (storage._zip) { if (storage._zip) {
queue = new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return storage._zip; return storage._zip;
}); });
} else {
queue = storage._unzip_queue;
} }
} else { return storage._unzip_queue;
throw storage._error;
} }
return queue; throw storage._error;
} }
...@@ -119,21 +115,11 @@ ...@@ -119,21 +115,11 @@
id = restrictDocumentId(id); id = restrictDocumentId(id);
return loadZip(this) return loadZip(this)
.push(function (zip) { .push(function (zip) {
var filename,
file;
if (id === "") { if (id === "") {
return {}; return {};
} }
for (filename in zip.files) { if (zip.files.hasOwnProperty(id) && zip.files[id].dir) {
if (zip.files.hasOwnProperty(filename)) { return {};
if (filename + '/' === id) {
file = zip.files[filename];
if (!file.dir) {
throw new jIO.util.jIOError("Cannot find document", 404);
}
return {};
}
}
} }
throw new jIO.util.jIOError("Cannot find document", 404); throw new jIO.util.jIOError("Cannot find document", 404);
}); });
......
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