fix: Bug - Files lose host on reload
Persist large uploads under app data on publish and restore, and re-announce hosted attachments after reload so peers can download again. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+37
-2
@@ -12,7 +12,7 @@ import { isSharingFromThisDevice } from '../../domain/logic/attachment-sharing.r
|
||||
import {
|
||||
canReceiveAttachment,
|
||||
isAttachmentMedia,
|
||||
shouldCopyUploaderMediaToAppData,
|
||||
shouldCopyLargeUploaderFileToAppData,
|
||||
shouldPersistDownloadedAttachment,
|
||||
shouldStreamAttachmentReceiveToDisk
|
||||
} from '../../domain/logic/attachment.logic';
|
||||
@@ -764,7 +764,7 @@ export class AttachmentTransferService {
|
||||
return;
|
||||
}
|
||||
|
||||
if (shouldCopyUploaderMediaToAppData(
|
||||
if (shouldCopyLargeUploaderFileToAppData(
|
||||
attachment,
|
||||
attachment.filePath,
|
||||
this.attachmentStorage.canCopyFiles()
|
||||
@@ -782,6 +782,41 @@ export class AttachmentTransferService {
|
||||
}
|
||||
}
|
||||
|
||||
async reannounceHostedAttachments(currentUserId: string | null | undefined): Promise<void> {
|
||||
if (!currentUserId) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const [, attachments] of this.runtimeStore.getAttachmentEntries()) {
|
||||
for (const attachment of attachments) {
|
||||
if (!isSharingFromThisDevice(attachment, currentUserId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const canServe = await this.attachmentStorage.resolveExistingPath(attachment);
|
||||
|
||||
if (!canServe) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const fileAnnounceEvent: FileAnnounceEvent = {
|
||||
type: 'file-announce',
|
||||
messageId: attachment.messageId,
|
||||
file: {
|
||||
id: attachment.id,
|
||||
filename: attachment.filename,
|
||||
size: attachment.size,
|
||||
mime: attachment.mime,
|
||||
isImage: attachment.isImage,
|
||||
uploaderPeerId: attachment.uploaderPeerId
|
||||
}
|
||||
};
|
||||
|
||||
this.webrtc.broadcastMessage(fileAnnounceEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async applySavedPathObjectUrl(attachment: Attachment, savedPath: string | null): Promise<void> {
|
||||
if (!savedPath) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user