mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop: Fixes existing attachments not being shared in some cases with Joplin Server
This commit is contained in:
parent
1d4e3fe3ea
commit
7ebc98633a
@ -311,11 +311,14 @@ describe('models/Folder.sharing', () => {
|
||||
expect(resource.share_id).toBe('');
|
||||
}
|
||||
|
||||
const previousBlobUpdatedTime = (await Resource.load(resourceId)).blob_updated_time;
|
||||
await msleep(1);
|
||||
await Folder.updateAllShareIds(resourceService);
|
||||
|
||||
{
|
||||
const resource: ResourceEntity = await Resource.load(resourceId);
|
||||
expect(resource.share_id).toBe(note1.share_id);
|
||||
expect(resource.blob_updated_time).toBeGreaterThan(previousBlobUpdatedTime);
|
||||
}
|
||||
|
||||
await Note.save({ id: note1.id, parent_id: folder2.id });
|
||||
|
@ -417,6 +417,7 @@ export default class Folder extends BaseItem {
|
||||
share_id: string;
|
||||
is_shared: number;
|
||||
resource_is_shared: number;
|
||||
resource_share_id: string;
|
||||
}
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
@ -426,7 +427,12 @@ export default class Folder extends BaseItem {
|
||||
// same time we also process the is_shared property.
|
||||
|
||||
const rows = (await this.db().selectAll(`
|
||||
SELECT r.id, n.share_id, n.is_shared, r.is_shared as resource_is_shared
|
||||
SELECT
|
||||
r.id,
|
||||
n.share_id,
|
||||
n.is_shared,
|
||||
r.is_shared as resource_is_shared,
|
||||
r.share_id as resource_share_id
|
||||
FROM note_resources nr
|
||||
LEFT JOIN resources r ON nr.resource_id = r.id
|
||||
LEFT JOIN notes n ON nr.note_id = n.id
|
||||
@ -513,7 +519,15 @@ export default class Folder extends BaseItem {
|
||||
updated_time: now,
|
||||
};
|
||||
|
||||
if (row.is_shared !== row.resource_is_shared) {
|
||||
// When a resource becomes published or shared, we set
|
||||
// `blob_updated_time` to ensure that the resource content
|
||||
// is uploaded too during the next sync operation.
|
||||
//
|
||||
// This is necessary because Joplin Server needs to
|
||||
// associate `share_id` or `is_shared` with the resource
|
||||
// content for sharing to work. Otherwise the share
|
||||
// recipient will only get the resource metadata.
|
||||
if (row.is_shared !== row.resource_is_shared || row.share_id !== row.resource_share_id) {
|
||||
resource.blob_updated_time = now;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user