Having backups in the same directory is too brittle. Rolling back if a validation has failed implies adding code to move old files around, which has to be tested and its bugs addressed. An uniform CAF API that handled the case, like
use CAF::VersionControl;
use CAF::FileWriter;
...
my $vc = CAF::VersionControl->new();
my $f1 = CAF::FileWriter->new(...);
my $f2 = CAF::FileWriter->new(...);
$vc->add($f1, $f2);
print $f1;
$fh->close();
if (config_is_sane()) {
$vc->commit();
} else {
$vc->revert();
}
Or something similar. We can rely on Git directly, using GIT_DIR and GIT_WORK_TREEenvironment variables or use etckeeper.
Having backups in the same directory is too brittle. Rolling back if a validation has failed implies adding code to move old files around, which has to be tested and its bugs addressed. An uniform
CAF
API that handled the case, likeOr something similar. We can rely on Git directly, using
GIT_DIR
andGIT_WORK_TREE
environment variables or use etckeeper.