~kaction/nix-sys

84007ad462b83aa91d6ad06cc9359244ed6c1cc6 — Dmitry Bogatov 1 year, 13 days ago 557a6bf master nix-sys/0.1.0
nix-sys: handle when there are no previous generation

This is basic situation -- everybody has to start somewhere, but when
developing on live system, I never actually tested with fresh state.
1 files changed, 3 insertions(+), 1 deletions(-)

M nix-sys/main.c
M nix-sys/main.c => nix-sys/main.c +3 -1
@@ 201,13 201,15 @@ int xopen_cdb(struct cdb *cdbp, const char *filename, int missing_ok)
int make_backup(struct cdb *cdbp, const char *target, const char *backup)
{
	int err;
	int cdb_valid;

	write2("checking if ");
	write2_s(target);
	write2(" needs backup... ");

	cdb_valid = cdbp->cdb_fd >= 0;
	/* In old generation, nothing to do. */
	if (cdb_find(cdbp, target, strlen(target) + 1) == 1) {
	if (cdb_valid && cdb_find(cdbp, target, strlen(target) + 1) == 1) {
		write2("no\n");
		return 0;
	}