From 2cc948a50cd8d57aaba60af6856a04c86d0d61b1 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sat, 1 Jun 2013 08:31:47 +0200 Subject: [PATCH] Removes instead of renananig new partially recovered files when aborting. --- HISTORY | 4 ++-- check.c | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/HISTORY b/HISTORY index 8dd9633c..3543ca15 100644 --- a/HISTORY +++ b/HISTORY @@ -4,8 +4,8 @@ SnapRAID HISTORY 3.1 2013/5 ========== * Direct use of Windows API for disk access to improve error reporting. - * If the 'fix' process is aborted, renames to .unrecoverable all the new - files created, to allow to reuse again the '-m, --filter-missing' flag. + * If the 'fix' process is aborted, it removes all the new files partially + recovered, to allow to reuse again the '-m, --filter-missing' flag. * In Windows don't exclude anymore system files. Only system directories are excluded. * In Windows applies filters in case insensitive way. diff --git a/check.c b/check.c index 585e0f1a..78dc40a2 100644 --- a/check.c +++ b/check.c @@ -1433,7 +1433,7 @@ bail: } } - /* rename all the files created from scratch that have not finished the processing */ + /* remove all the files created from scratch that have not finished the processing */ /* it happens only when aborting */ if (fix) { /* for each disk */ @@ -1449,7 +1449,6 @@ bail: node = disk->filelist; while (node) { char path[PATH_MAX]; - char path_to[PATH_MAX]; struct snapraid_file* file; file = node->data; @@ -1470,14 +1469,11 @@ bail: /* if the file was originally missing, and processing not yet finished */ /* we have to throw it away to ensure that at the next run we will retry */ /* to fix it, in case we select to undelete missing files */ - - /* rename it to .unrecoverable */ pathprint(path, sizeof(path), "%s%s", disk->dir, file->sub); - pathprint(path_to, sizeof(path_to), "%s%s.unrecoverable", disk->dir, file->sub); - ret = rename(path, path_to); + ret = remove(path); if (ret != 0) { - fprintf(stderr, "Error renaming '%s' to '%s'. %s.\n", path, path_to, strerror(errno)); + fprintf(stderr, "Error removing '%s'. %s.\n", path, strerror(errno)); fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n"); ++unrecoverable_error; /* continue, as we are already exiting */