batou icon indicating copy to clipboard operation
batou copied to clipboard

batou.lib.file.Directory: Allow to explcit overwrite target directory

Open frlan opened this issue 2 years ago • 2 comments

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

frlan avatar Aug 12 '22 12:08 frlan

Alternatively we could allow setting rsync flags explicitly.

ctheune avatar Aug 26 '22 06:08 ctheune

Like forwarding verify_opts and sync_opts -- yepp that should work, too

frlan avatar Aug 26 '22 06:08 frlan

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

elikoga avatar Dec 19 '23 02:12 elikoga

I think I'd be fine with folding it into Directory.

ctheune avatar Dec 19 '23 06:12 ctheune