batou
batou copied to clipboard
batou.lib.file.Directory: Allow to explcit overwrite target directory
batou.lib.file.Directory() should get a flag to either append or overwrite (-> rsync --delete) the contents of a target directory based on given source folder.
Usecase:
When synching sourcecode via e.g. something like
self += Directory(
"docroot",
source=os.path.join(self.root.defdir, "..", "..", "docroot"),
exclude=["/docroot/wp-config.php", "/docroot/.htaccess"],
)
it might happen that deleted files are not gone after. On the other hand making deletion a default would be dangerous
Alternatively we could allow setting rsync flags explicitly.
Like forwarding verify_opts
and sync_opts
-- yepp that should work, too
like this:
self += Directory(
"docroot",
source=os.path.join(self.root.defdir, "..", "..", "docroot"),
exclude=["/docroot/wp-config.php", "/docroot/.htaccess"],
sync_opts="--inplace -lr --delete"
)
?
Do we want to build that into Directory
, instead of splitting the described usage described into a call of Directory
and a call of SyncDirectory
with the arguments like this?
self += Directory(
"docroot",
)
self += SyncDirectory(
"docroot",
source=os.path.join(self.root.defdir, "..", "..", "docroot"),
exclude=["/docroot/wp-config.php", "/docroot/.htaccess"],
sync_opts="--inplace -lr --delete"
)
which should work with the current SyncDirectory
implementation
I think I'd be fine with folding it into Directory.