New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
archiver: Shortcut for handling empty files #4267
base: master
Are you sure you want to change the base?
Conversation
Regular files that are empty according to stat are now not opened for reading their contents. Such files are quite common (in my homedir, at least) and we can save multiple system calls this way. On a network filesystem, that can mean round trips. Also, we can back up empty files that we cannot open for reading. Finally, fixes restic#4257. Existing tests cover this case. fs.Reader now no longer has a meaningful Size. Nothing depended on that.
Empty files may not be empty. What is about e.g. |
I second this opinion. |
I don't find the /proc example compelling at all, and we have at least one example were an empty file not being empty is exactly what is causing trouble. |
Programs should not try to be more clever than me ;) |
What about a broader approach like
or similiar. But, OTOH this duplicates things we can achive better using |
I'm not sure I get you completely, but I certainly want the empty files in, not skipped. I just want don't want to actually open them if lstat says they're empty. |
You are correct, I missed that point. Creating a list of files to back up would not help here. Just as the suggested filter would not help. So maybe you're suggesting a new option as |
What does this PR change? What problem does it solve?
Regular files that are empty according to stat are now not opened for reading their contents. Such files are quite common (in my homedir, at least) and we can save multiple system calls this way. On a network filesystem, that can mean round trips. Also, we can back up empty files that we cannot open for reading. Finally, fixes #4257.
Existing tests cover this case. fs.Reader now no longer has a meaningful Size. Nothing depended on that.
I tested restic backup --stdin on the command line and it still works. It also still gives the same error for empty stdin.
Was the change previously discussed in an issue or on the forum?
Fixes #4257.
Checklist
changelog/unreleased/
that describes the changes for our users (see template).gofmt
on the code in all commits.