Skip to content

Add EPERM copy fallback - #5668

Merged
advplyr merged 3 commits into
advplyr:masterfrom
nichwall:fix/issue-5637-copy-fallback
Oct 22, 2026
Merged

advplyr merged 3 commits into
advplyr:masterfrom
nichwall:fix/issue-5637-copy-fallback

Conversation

@nichwall

Copy link
Copy Markdown
Contributor

Brief summary

This PR adds a copy failure of EPERM fallback.

Which issue is fixed?

Fixes #5637

In-depth Description

This PR adds a fallback function when copyFileSync fails using node 24.
I am not able to reproduce the original issue on my machines, and the issue seems specific to TrueNAS but there may also be other setups that have the same issue.

If an EPERM error is thrown when trying to copy the file, a 1 MB buffer is created to stream the source file to the destination file. I chose to stream through a buffer instead of just replacing with writeFileSync because that will load the entire file into memory before writing, which could cause issues when copying the database or other large files.

The rename function was also updated to attempt the streaming copy when an EPERM error occurs.

How have you tested this?

Created minimal tests to make sure the fallback works and ensured the server started correctly on Linux.

Because I cannot recreate the issue myself, this should probably be tested in :edge.

Screenshots

N/A

@advplyr

advplyr commented Oct 22, 2026

Copy link
Copy Markdown
Owner

I don't think we should change the copy-sync and move-sync because those aren't used at all. Thanks!

@advplyr
advplyr merged commit 9715c7a into advplyr:master Oct 22, 2026
5 checks passed
@nichwall
nichwall deleted the fix/issue-5637-copy-fallback branch October 22, 2026 22:43
@nichwall

Copy link
Copy Markdown
Contributor Author

That makes sense. I did some reading and it looks like pretty much everything the fs-extra library does is included as part of node now anyway, but that's a larger change so doesn't need to happen yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants