You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-06 23:56:13 +02:00
All: Fixes #5223: Fixed issue with orphaned resource being created in case of a resource conflict
This commit is contained in:
@ -389,15 +389,31 @@ export default class Resource extends BaseItem {
|
||||
return newResource;
|
||||
}
|
||||
|
||||
static async createConflictResourceNote(resource: ResourceEntity) {
|
||||
const Note = this.getClass('Note');
|
||||
public static async resourceConflictFolderId(): Promise<string> {
|
||||
const folder = await this.resourceConflictFolder();
|
||||
return folder.id;
|
||||
}
|
||||
|
||||
private static async resourceConflictFolder(): Promise<any> {
|
||||
const conflictFolderTitle = _('Conflicts (attachments)');
|
||||
const Folder = this.getClass('Folder');
|
||||
|
||||
const folder = await Folder.loadByTitle(conflictFolderTitle);
|
||||
if (!folder || folder.parent_id) {
|
||||
return Folder.save({ title: conflictFolderTitle });
|
||||
}
|
||||
|
||||
return folder;
|
||||
}
|
||||
|
||||
public static async createConflictResourceNote(resource: ResourceEntity) {
|
||||
const Note = this.getClass('Note');
|
||||
const conflictResource = await Resource.duplicateResource(resource.id);
|
||||
|
||||
await Note.save({
|
||||
title: _('Attachment conflict: "%s"', resource.title),
|
||||
body: _('There was a [conflict](%s) on the attachment below.\n\n%s', 'https://joplinapp.org/conflict/', Resource.markdownTag(conflictResource)),
|
||||
is_conflict: 1,
|
||||
parent_id: await this.resourceConflictFolderId(),
|
||||
}, { changeSource: ItemChange.SOURCE_SYNC });
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user