Stop uploading files on quota error until next manual sync or restart

This commit is contained in:
Dan Stillman 2019-06-22 05:28:02 -04:00
parent 94795095f2
commit ead93b6ccc
5 changed files with 123 additions and 44 deletions

View file

@ -1001,16 +1001,20 @@ describe("Zotero.Sync.Storage.Mode.ZFS", function () {
item.synced = true;
yield item.saveTx();
var responses = 0;
server.respond(function (req) {
if (req.method == "POST"
&& req.url == `${baseURL}users/1/items/${item.key}/file`
&& req.requestBody.indexOf('upload=') == -1
&& req.requestHeaders["If-None-Match"] == "*") {
responses++;
req.respond(
413,
{
"Content-Type": "application/json",
"Last-Modified-Version": 10
"Last-Modified-Version": 10,
"Zotero-Storage-Usage": "300",
"Zotero-Storage-Quota": "300"
},
"File would exceed quota (299.7 + 0.5 > 300)"
);
@ -1024,6 +1028,19 @@ describe("Zotero.Sync.Storage.Mode.ZFS", function () {
assert.equal(e.errorType, 'warning');
assert.include(e.message, 'test.png');
assert.equal(e.dialogButtonText, Zotero.getString('sync.storage.openAccountSettings'));
assert.equal(responses, 1);
// Try again
var e = yield getPromiseError(zfs.uploadFile({
name: item.libraryKey
}));
assert.ok(e);
assert.equal(e.errorType, 'warning');
assert.include(e.message, 'test.png');
assert.equal(e.dialogButtonText, Zotero.getString('sync.storage.openAccountSettings'));
// Shouldn't have been another request. A manual sync resets the flag, but we're not
// testing that here.
assert.equal(responses, 1);
})
})
})