mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
All: Allow excluding certain keys during sync
This commit is contained in:
parent
124a959c8d
commit
d66fa87b2b
@ -288,7 +288,19 @@ class BaseItem extends BaseModel {
|
||||
|
||||
static async serializeForSync(item) {
|
||||
const ItemClass = this.itemClass(item);
|
||||
let serialized = await ItemClass.serialize(item);
|
||||
let shownKeys = ItemClass.fieldNames();
|
||||
shownKeys.push('type_');
|
||||
|
||||
if (ItemClass.serializeForSyncExcludedKeys) {
|
||||
const keys = ItemClass.serializeForSyncExcludedKeys();
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const idx = shownKeys.indexOf(keys[i]);
|
||||
shownKeys.splice(idx, 1);
|
||||
}
|
||||
}
|
||||
|
||||
const serialized = await ItemClass.serialize(item, shownKeys);
|
||||
|
||||
if (!Setting.value('encryption.enabled') || !ItemClass.encryptionSupported()) {
|
||||
// Normally not possible since itemsThatNeedSync should only return decrypted items
|
||||
if (!!item.encryption_applied) throw new JoplinError('Item is encrypted but encryption is currently disabled', 'cannotSyncEncrypted');
|
||||
@ -312,7 +324,6 @@ class BaseItem extends BaseModel {
|
||||
|
||||
reducedItem.encryption_applied = 1;
|
||||
reducedItem.encryption_cipher_text = cipherText;
|
||||
|
||||
return ItemClass.serialize(reducedItem)
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,10 @@ class Resource extends BaseItem {
|
||||
return resource.id + extension;
|
||||
}
|
||||
|
||||
static serializeForSyncExcludedKeys() {
|
||||
return ['fetch_status', 'fetch_error'];
|
||||
}
|
||||
|
||||
static friendlyFilename(resource) {
|
||||
let output = safeFilename(resource.title); // Make sure not to allow spaces or any special characters as it's not supported in HTTP headers
|
||||
if (!output) output = resource.id;
|
||||
|
Loading…
Reference in New Issue
Block a user