Skip to content

fix: forward message with file#7755

Merged
Hocuri merged 7 commits intomainfrom
ndh/forward-message-with-file
Jan 22, 2026
Merged

fix: forward message with file#7755
Hocuri merged 7 commits intomainfrom
ndh/forward-message-with-file

Conversation

@nicodh
Copy link
Copy Markdown
Contributor

@nicodh nicodh commented Jan 20, 2026

resolves #7724

src/chat.rs Outdated
Ok(src_blob) => {
let src_path = src_blob.to_abs_path();
let filename = param.get(Param::Filename).unwrap_or("file");
match BlobObject::create_and_deduplicate(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR: This calls std::fs::copy() which supports FS-level deduplication, e.g. on Linux it does copy_file_range(). So on modern FSes like btrfs there's no big overhead

src/chat.rs Outdated
// because each account has its own blob directory.
if let Some(file_name) = param.get(Param::File) {
let src_blob = BlobObject::from_name(ctx_src, file_name)
.with_context(|| format!("Failed to get source blob: {file_name}"))?;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.with_context(|| format!("Failed to get source blob: {file_name}"))?;
.with_context(|| format!("Get source blob: {file_name}"))?;

Usually "Failed to..." or "Error while..." already exists inside the error string so i'd avoid adding it, otherwise the final error looks like "Failed to get source blob: Failed to get blob path: ..."

src/chat.rs Outdated
let filename = param.get(Param::Filename).unwrap_or("file");
let new_blob =
BlobObject::create_and_deduplicate(ctx_dst, &src_path, Path::new(filename))
.context("Failed to copy blob file to destination account")?;
Copy link
Copy Markdown
Collaborator

@iequidoo iequidoo Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.context("Failed to copy blob file to destination account")?;
.context("BlobObject::create_and_deduplicate")?;

Maybe even this way. Users won't understand the error message anyway, it's too technical and untranslated. I think it's important that some error is shown, but its content is for developers mainly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I do like understanding what went wrong just from reading the error message. Also, it's easier to grep for "Failed to copy blob file to destination account" than for "BlobObject::create_and_deduplicate".

alice.send_msg(alice_self_chat.id, &mut msg).await;
let alice_self_msg = alice.get_last_msg().await;

// Delete the blob file from Alice's blobdir to simulate a missing file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good as is, but consider merging this part into the previous test to reduce amount of code. Test failure reports will be less informative, but not sure that it's important currently

src/chat.rs Outdated
let filename = param.get(Param::Filename).unwrap_or("file");
let new_blob =
BlobObject::create_and_deduplicate(ctx_dst, &src_path, Path::new(filename))
.context("Failed to copy blob file to destination account")?;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I do like understanding what went wrong just from reading the error message. Also, it's easier to grep for "Failed to copy blob file to destination account" than for "BlobObject::create_and_deduplicate".

@Hocuri Hocuri enabled auto-merge (squash) January 22, 2026 19:51
@Hocuri
Copy link
Copy Markdown
Collaborator

Hocuri commented Jan 22, 2026

@adbenitez wants a core release, let's get this fix in first

@Hocuri Hocuri merged commit a6baba1 into main Jan 22, 2026
30 checks passed
@Hocuri Hocuri deleted the ndh/forward-message-with-file branch January 22, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forwarding to other profile fails when message has file attached

3 participants