Skip to content
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

create: implement --paths-from-stdin and --paths-from-command #5538

Merged
merged 8 commits into from
Dec 6, 2020

Conversation

Lapin0t
Copy link
Contributor

@Lapin0t Lapin0t commented Dec 3, 2020

WIP. Follow-up of #5492. Implement two switches which shortcut the filesystem-walking logic completely: borg will read the paths and backup without doing any recursion (directories can --and should-- be passed). Should honor any relevant option (common options and all filesystem option but --one-file-system).

Slight change from my earlier proposal: now if either --paths-from-stdin or --paths-from-command are given, then it won't process any normal path from args.path. In --path-from-command it wouldn't make sense anyway since args.path is being used for the command. Technically, for --paths-from-stdin we could still handle args.path as usual but it's probably safe to assume that a user don't want to mix both things. Besides it simplifies the code and the top-level behavior of create.

WIP: Just wrote, didn't execute! :) I should verify if it works correctly and add unit tests to the PR.

@ThomasWaldmann
Copy link
Member

src/borg/archiver.py:548:22: E261 at least two spaces before inline comment
src/borg/helpers/misc.py:217:1: E302 expected 2 blank lines, found 1

after you fix that, the real tests will run.

@ThomasWaldmann
Copy link
Member

--path-from-command <-- there seems to be an "s" missing.

can you fix the commit comment, the PR top post, etc., please?

Copy link
Member

@ThomasWaldmann ThomasWaldmann left a comment

Choose a reason for hiding this comment

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

thanks for the PR, nice powerful functionality!

src/borg/archiver.py Outdated Show resolved Hide resolved
src/borg/archiver.py Outdated Show resolved Hide resolved
src/borg/archiver.py Outdated Show resolved Hide resolved
@ThomasWaldmann ThomasWaldmann added this to the hydrogen-beta1 milestone Dec 4, 2020
@ThomasWaldmann
Copy link
Member

would be cool to get this into 1.2.0b1 (soon).

These switches reads paths to archive from stdin. Delimiter can specified
by --paths-delimiter=DELIM. Paths read will be added honoring every
option but exclusion options and --one-file-system. Directories aren't
recursed into.
@Lapin0t
Copy link
Contributor Author

Lapin0t commented Dec 5, 2020

Sorry for the force-push, i needed to edit the commit message...

@Lapin0t Lapin0t changed the title Implement --paths-from-stdin and --path-from-command for borg create. Implement --paths-from-stdin and --paths-from-command for borg create. Dec 5, 2020
@codecov-io
Copy link

codecov-io commented Dec 5, 2020

Codecov Report

Merging #5538 (fcbb43d) into master (9fa28df) will increase coverage by 0.04%.
The diff coverage is 77.35%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5538      +/-   ##
==========================================
+ Coverage   83.08%   83.13%   +0.04%     
==========================================
  Files          38       38              
  Lines       10003    10054      +51     
  Branches     1657     1668      +11     
==========================================
+ Hits         8311     8358      +47     
- Misses       1202     1203       +1     
- Partials      490      493       +3     
Impacted Files Coverage Δ
src/borg/archiver.py 80.25% <69.23%> (-0.14%) ⬇️
src/borg/helpers/misc.py 80.62% <100.00%> (+1.57%) ⬆️
src/borg/helpers/parseformat.py 89.88% <100.00%> (+0.03%) ⬆️
src/borg/archive.py 81.44% <0.00%> (+0.26%) ⬆️
src/borg/helpers/fs.py 86.66% <0.00%> (+1.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fa331c3...fcbb43d. Read the comment docs.

@ThomasWaldmann
Copy link
Member

No problem, there is no other way than to force-push if one edits history.

Shall I merge it like this for now and we check the bytes vs. text paths later?

@Lapin0t
Copy link
Contributor Author

Lapin0t commented Dec 5, 2020

No wait a bit, i'm testing it and there is a weird bug, it's really not doing what it should.

@ThomasWaldmann
Copy link
Member

guess a test would be fine also.

@Lapin0t
Copy link
Contributor Author

Lapin0t commented Dec 5, 2020

Ok, this should be fine now. The tests are mostly copy&paste from content-from-command.. not really exhaustive in any way neither. About the text/binary thing, i realized proc.stdout was already in binary mode by default, so i just changed sys.stdin.buffer and wrapped the whole thing in textmode with surrogateescape which seems to be the right thing to do when handling paths (i saw there are some helpers already doing that kind of encoding so maybe you know more about it).

src/borg/archiver.py Outdated Show resolved Hide resolved
src/borg/testsuite/helpers.py Outdated Show resolved Hide resolved
src/borg/helpers/misc.py Show resolved Hide resolved
src/borg/helpers/misc.py Outdated Show resolved Hide resolved
src/borg/helpers/misc.py Outdated Show resolved Hide resolved
src/borg/testsuite/helpers.py Outdated Show resolved Hide resolved
src/borg/testsuite/helpers.py Outdated Show resolved Hide resolved
src/borg/archiver.py Outdated Show resolved Hide resolved
src/borg/testsuite/helpers.py Outdated Show resolved Hide resolved
@ThomasWaldmann ThomasWaldmann changed the title Implement --paths-from-stdin and --paths-from-command for borg create. create: implement --paths-from-stdin and --paths-from-command Dec 6, 2020
@ThomasWaldmann ThomasWaldmann merged commit e1af909 into borgbackup:master Dec 6, 2020
@ThomasWaldmann
Copy link
Member

Thanks! Merged!

I created a related issue #5551.

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.

3 participants