Skip to content

Use FileUtils.cp for local send_file when no user switch needed#403

Closed
neidiom wants to merge 1 commit intoitamae-kitchen:masterfrom
neidiom:fix/issue-44-local-send-file
Closed

Use FileUtils.cp for local send_file when no user switch needed#403
neidiom wants to merge 1 commit intoitamae-kitchen:masterfrom
neidiom:fix/issue-44-local-send-file

Conversation

@neidiom
Copy link
Contributor

@neidiom neidiom commented Mar 3, 2026

The existing shell pipeline (cat src | sudo cat > dst) is necessary when switching users, since sudo handles writing as a different user. But for the common case with no user switch, piping through cat is redundant — FileUtils.cp is simpler, avoids spawning shell processes, and makes the intent clearer.

Copy link
Member

@unasuke unasuke left a comment

Choose a reason for hiding this comment

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

The description says the shell pipeline was "unnecessarily complex," but after this change, the pipeline still remains for the user case, and adding a branch on top of it.

When no user switch is required, use FileUtils.cp instead of
piping through cat, avoiding an unnecessary shell pipeline for
the common case.
@neidiom neidiom force-pushed the fix/issue-44-local-send-file branch from 89c8770 to 5931dde Compare March 4, 2026 12:04
@neidiom
Copy link
Contributor Author

neidiom commented Mar 4, 2026

The description says the shell pipeline was "unnecessarily complex," but after this change, the pipeline still remains for the user case, and adding a branch on top of it.

Please check now.

@unasuke
Copy link
Member

unasuke commented Mar 4, 2026

Please check now.

@neidiom What changes have been made since my last review comment?

@neidiom
Copy link
Contributor Author

neidiom commented Mar 4, 2026

Please check now.

@neidiom What changes have been made since my last review comment?

I updated the description.

@unasuke
Copy link
Member

unasuke commented Mar 4, 2026

@neidiom Understood, thank you. However, I still prefer the current more generic code over adding an if-branch to use FileUtils.cp.

@neidiom
Copy link
Contributor Author

neidiom commented Mar 4, 2026

@neidiom Understood, thank you. However, I still prefer the current more generic code over adding an if-branch to use FileUtils.cp.

ok. Shall we close the PR :)

@unasuke unasuke closed this Mar 4, 2026
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.

2 participants