Always include 'contentType'/'charset'/'filename' in attachment JSON
And omit in ZFS file sync requests The API previously didn't allow these properties to be set for group items, because they were set atomically during the file upload process, but 1) that's not really necessary (makes a little sense for 'filename', but not really a big deal if an old file is renamed on another computer before the new file is synced down) and 2) skipping them results in the properties getting erased after items are uploaded and the empty values returned by the server overwrite the local values.
This commit is contained in:
parent
4ffd35dff2
commit
99eb39e288
6 changed files with 29 additions and 37 deletions
|
@ -1051,6 +1051,22 @@ describe("Zotero.Item", function () {
|
|||
assert.equal(json.md5, (yield item.attachmentHash));
|
||||
})
|
||||
|
||||
it("should omit storage values with .skipStorageProperties", function* () {
|
||||
var file = getTestDataDirectory();
|
||||
file.append('test.png');
|
||||
var item = yield Zotero.Attachments.importFromFile({ file });
|
||||
|
||||
item.attachmentSyncedModificationTime = new Date().getTime();
|
||||
item.attachmentSyncedHash = 'b32e33f529942d73bea4ed112310f804';
|
||||
yield item.saveTx({ skipAll: true });
|
||||
|
||||
var json = item.toJSON({
|
||||
skipStorageProperties: true
|
||||
});
|
||||
assert.isUndefined(json.mtime);
|
||||
assert.isUndefined(json.md5);
|
||||
});
|
||||
|
||||
it("should output synced storage values with .syncedStorageProperties", function* () {
|
||||
var item = new Zotero.Item('attachment');
|
||||
item.attachmentLinkMode = 'imported_file';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue