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

Add verify_opts and sync_opts to Directory class #427

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/batou/lib/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,22 @@ class Directory(Component):
source = None
exclude = ()

verify_opts = None
sync_opts = None

def configure(self):
self.path = self.map(self.path)
if self.source:
# XXX The ordering is wrong. SyncDirectory should run *after*.
self += SyncDirectory(
self.path, source=self.source, exclude=self.exclude
)
args = {
"source": self.source,
"exclude": self.exclude,
}
if self.verify_opts:
args["verify_opts"] = self.verify_opts
if self.sync_opts:
args["sync_opts"] = self.sync_opts
self += SyncDirectory(self.path, **args)

def verify(self):
assert os.path.isdir(self.path)
Expand Down
11 changes: 11 additions & 0 deletions src/batou/lib/tests/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,3 +1153,14 @@ def test_syncdirectory_needs_update_on_nonexisting_target(root):
with pytest.raises(batou.UpdateNeeded):
sd = SyncDirectory("non_existing_dir", source="existing_dir")
sd.verify()


def test_directory_passes_args_to_syncdirectory(root):
d = Directory(
"target", source="source", verify_opts="-abc", sync_opts="-xyz"
)
d.prepare(root.component)
sd = d._
assert isinstance(sd, SyncDirectory)
assert sd.verify_opts == "-abc"
assert sd.sync_opts == "-xyz"
Loading