Removes instead of renananig new partially recovered files when aborting.

This commit is contained in:
Andrea Mazzoleni 2013-06-01 08:31:47 +02:00
parent 5fef489a25
commit 2cc948a50c
2 changed files with 5 additions and 9 deletions

View file

@ -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.

10
check.c
View file

@ -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 */