From 6d0145f3a667675b8baab48bfe9129aa9f745af0 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sat, 3 Sep 2011 10:12:13 +0200 Subject: [PATCH] Lists all the empty disks when asking for --force-empty. --- HISTORY | 3 ++- scan.c | 23 ++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/HISTORY b/HISTORY index b16b53c1..21aef339 100644 --- a/HISTORY +++ b/HISTORY @@ -6,7 +6,8 @@ SnapRAID HISTORY * In "diff" now it recognizes the reuse of inodes. * Windows hidden files are now backuped like any other files. * Symbolic links are now saved in *nix. Not supported in Windows. -* When fixing the original modification time of the files is restored. +* In fixing the original modification time of the files is also restored. +* The message asking to use the --force-empty option now lists all the empty disks. 1.5 2011/7 ========== diff --git a/scan.c b/scan.c index b15df040..d2e8f9fe 100644 --- a/scan.c +++ b/scan.c @@ -454,6 +454,7 @@ void state_scan(struct snapraid_state* state, int output) unsigned diskmax = tommy_array_size(&state->diskarr); unsigned i; struct snapraid_scan* scan; + int has_empty; scan = malloc_nofail(diskmax * sizeof(struct snapraid_scan)); for(i=0;idiskarr, i); - /* if all the previous file were removed */ if (scan[i].count_equal == 0 && scan[i].count_moved == 0 && scan[i].count_remove != 0) { - if (!state->force_empty) { - fprintf(stderr, "All the files previously present in disk '%s' at dir '%s' are now missing or overwritten!\n", disk->name, disk->dir); - fprintf(stderr, "If you really want to sync, use 'snapraid --force-empty sync'\n"); - exit(EXIT_FAILURE); + if (!has_empty) { + has_empty = 1; + fprintf(stderr, "All the files previously present in disk '%s' at dir '%s'", disk->name, disk->dir); + } else { + fprintf(stderr, ", disk '%s' at dir '%s'", disk->name, disk->dir); } } } + if (has_empty) { + fprintf(stderr, " are now missing or rewritten!\n"); + fprintf(stderr, "This happens with an empty disk or when all the files are recreated after a 'fix' command.\n"); + fprintf(stderr, "If you really want to sync, use 'snapraid --force-empty sync'.\n"); + exit(EXIT_FAILURE); + } if (state->verbose || output) { struct snapraid_scan total;