You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-13 00:10:37 +02:00
All: Allow modifying a resource metadata only when synchronising (#9114)
This commit is contained in:
@ -15,6 +15,7 @@ import JoplinError from '../JoplinError';
|
||||
import itemCanBeEncrypted from './utils/itemCanBeEncrypted';
|
||||
import { getEncryptionEnabled } from '../services/synchronizer/syncInfoUtils';
|
||||
import ShareService from '../services/share/ShareService';
|
||||
import { SaveOptions } from './utils/types';
|
||||
|
||||
export default class Resource extends BaseItem {
|
||||
|
||||
@ -372,9 +373,15 @@ export default class Resource extends BaseItem {
|
||||
// We first save the resource metadata because this can throw, for
|
||||
// example if modifying a resource that is read-only
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
const result = await Resource.save({
|
||||
id: resource.id,
|
||||
size: fileStat.size,
|
||||
updated_time: now,
|
||||
blob_updated_time: now,
|
||||
}, {
|
||||
autoTimestamp: false,
|
||||
});
|
||||
|
||||
// If the above call has succeeded, we save the data blob
|
||||
@ -442,10 +449,18 @@ export default class Resource extends BaseItem {
|
||||
}, { changeSource: ItemChange.SOURCE_SYNC });
|
||||
}
|
||||
|
||||
// public static async save(o: ResourceEntity, options: SaveOptions = null): Promise<ResourceEntity> {
|
||||
// const resource:ResourceEntity = await super.save(o, options);
|
||||
// if (resource.updated_time) resource.bl
|
||||
// return resource;
|
||||
// }
|
||||
public static async save(o: ResourceEntity, options: SaveOptions = null): Promise<ResourceEntity> {
|
||||
const resource = { ...o };
|
||||
|
||||
if (this.isNew(o, options)) {
|
||||
const now = Date.now();
|
||||
options = { ...options, autoTimestamp: false };
|
||||
if (!resource.created_time) resource.created_time = now;
|
||||
if (!resource.updated_time) resource.updated_time = now;
|
||||
if (!resource.blob_updated_time) resource.blob_updated_time = now;
|
||||
}
|
||||
|
||||
return await super.save(resource, options);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user