-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
- The
updateHook
is required for saveFile and deleteFile in AttachmentQueue. Why is it required? In my personal use-case, I’ve never used updateHook. - The
updateHook
can confuse people. When I tried to useupdateHook
insaveFile
I needed toUPDATE ${AttachmentsQueueTable.defaultTableName} SET message_id = ? WHERE id =
, and it didn’t work, becauseupdateHook
is called before it inserted into attachments queue table, therefore I couldn’t execute update statement. It can be solved by introducing preUpdateHook and postUpdateHook, or something like that. Or we could have a single updateHook, but call it after the*await* attachmentContext.upsertAttachment(attachment, tx);
, in the saveFile specifically. - When calling
deleteFile
, first it checks if attachment exists in the queue. If it doesn’t, attachment not found exception is thrown. It makes sense, but in my specific use-case I can calldeleteFile
mostly to delete attachment from the remote storage, sometimes it may not be inside the attachments queue, therefore it won’t be deleted. I have to call both deleteFile from AttachmentsQueue and RemoteStorage(which deletes from Supabase storage) in order to ensure that even when sometimes attachment may not exist in the queue, the attachment is 100% deleted from the storage. I’m just sharing about my experience and not sure whether anything needs to be touched here.
/// Resolves the filename for new attachment items.
/// Concatenates the attachment ID and extension by default.
Future<String> resolveNewAttachmentFilename(
String attachmentId,
String? fileExtension,
) async {
return '$attachmentId.${fileExtension ?? 'dat'}';
}
Why you always append extension in the resolveNewAttachmentFilename
? Why just not append any extension if user has specifically not passed any extension(when fileExtension is null). I found it really frustrating. In old powersync_attachments_helper I could override those methods, but now AttachmentQueue is not extendable.
Metadata
Metadata
Assignees
Labels
No labels