Commit 2b211fb4 authored by Boris Kocherov's avatar Boris Kocherov

Revert "working but bad solution of "transaction close on onsuccess callback ended" problem."

This reverts commit 357d923c.
nexedi/rsvp.js!1 fix it by more elegant way
parent 8a325540
......@@ -303,7 +303,8 @@
};
IndexedDBStorage.prototype.getAttachment = function (id, name, options) {
var type,
var transaction,
type,
start,
end;
if (options === undefined) {
......@@ -311,32 +312,19 @@
}
return openIndexedDB(this)
.push(function (db) {
return new RSVP.Promise(function (resolve, reject) {
var transaction = openTransaction(db, ["attachment", "blob"],
"readonly"),
transaction = openTransaction(db, ["attachment", "blob"], "readonly");
// XXX Should raise if key is not good
request = transaction.objectStore("attachment")
.get(buildKeyPath([id, name]));
request.onerror = function (error) {
transaction.abort();
reject(error);
};
request.onsuccess = function () {
var attachment = request.result,
total_length,
return handleGet(transaction.objectStore("attachment")
.get(buildKeyPath([id, name])));
})
.push(function (attachment) {
var total_length = attachment.info.length,
i,
promise_list = [],
store = transaction.objectStore("blob"),
start_index,
end_index;
if (!attachment) {
return reject(
new jIO.util.jIOError("Cannot find attachment", 404)
);
}
total_length = attachment.info.length;
type = attachment.info.content_type;
start = options.start || 0;
end = options.end || total_length;
......@@ -365,9 +353,7 @@
name, i])))
);
}
resolve(RSVP.all(promise_list));
};
});
return RSVP.all(promise_list);
})
.push(function (result_list) {
var array_buffer_list = [],
......@@ -427,12 +413,10 @@
}
// Remove previous attachment
transaction = openTransaction(db, ["attachment", "blob"],
"readwrite", false);
transaction = openTransaction(db, ["attachment", "blob"], "readwrite");
return removeAttachment(transaction, id, name);
})
.push(function () {
transaction = openTransaction(db, ["attachment", "blob"], "readwrite");
var promise_list = [
handleRequest(transaction.objectStore("attachment").put({
......
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