Merge branch 'b4'

Conflicts:
	HISTORY
This commit is contained in:
Andrea Mazzoleni 2013-10-02 21:32:30 +02:00
commit ec172efb5c
5 changed files with 126 additions and 25 deletions

72
scan.c
View file

@ -467,37 +467,59 @@ static void scan_file(struct snapraid_scan* scan, struct snapraid_state* state,
|| file->mtime_nsec == STAT_NSEC_INVALID
)
) {
/* here we know that the inode is different and it needs to be updated */
/* otherwise we would have processed the file when searching by inode */
state->need_write = 1;
/* mark as present */
file_flag_set(file, FILE_IS_PRESENT);
/* always update the nano seconds mtime */
/* to manage the above STAT_NSEC_INVALID case */
file->mtime_nsec = STAT_NSEC(st);
/* update the nano seconds mtime only if different */
/* to avoid unneeded updates */
if (file->mtime_nsec == STAT_NSEC_INVALID
&& STAT_NSEC(st) != STAT_NSEC_INVALID
) {
file->mtime_nsec = STAT_NSEC(st);
/* if the inode is different, it means a rewritten file with the same path */
/* like when restoring a backup that restores also the timestamp */
++scan->count_restore;
if (state->opt.gui) {
fprintf(stdlog, "scan:restore:%s:%s\n", disk->name, sub);
fflush(stdlog);
}
if (output) {
printf("Restore '%s%s'\n", disk->dir, sub);
/* we have to save the new mtime */
state->need_write = 1;
}
/* remove from the inode set */
tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset);
/* if the disk support persistent inodes */
if (!disk->has_not_persistent_inodes) {
/* if persistent inodes are supported, we are sure that the inode number */
/* is now different, because otherwise the file would have been found */
/* when searching by inode. */
/* if the inode is different, it means a rewritten file with the same path */
/* like when restoring a backup that restores also the timestamp */
++scan->count_restore;
/* save the new inode */
file->inode = st->st_ino;
if (state->opt.gui) {
fprintf(stdlog, "scan:restore:%s:%s\n", disk->name, sub);
fflush(stdlog);
}
if (output) {
printf("Restore '%s%s'\n", disk->dir, sub);
}
/* reinsert in the inode set */
tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode));
/* remove from the inode set */
tommy_hashdyn_remove_existing(&disk->inodeset, &file->nodeset);
/* save the new inode */
file->inode = st->st_ino;
/* reinsert in the inode set */
tommy_hashdyn_insert(&disk->inodeset, &file->nodeset, file, file_inode_hash(file->inode));
/* we have to save the new inode */
state->need_write = 1;
} else {
/* otherwise it's the case of not persistent inode, where doesn't */
/* matter if the inode is different or equal, because they have no */
/* meaning, and then we don't even save them */
++scan->count_equal;
if (state->opt.gui) {
fprintf(stdlog, "scan:equal:%s:%s\n", disk->name, file->sub);
fflush(stdlog);
}
}
/* nothing more to do */
return;
@ -690,8 +712,8 @@ static int scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, in
pathprint(path_next, sizeof(path_next), "%s%s", dir, name);
pathprint(sub_next, sizeof(sub_next), "%s%s", sub, name);
/* check for not supported file names, limitation derived from the content file format */
if (name[0] == 0 || strchr(name, '\n') != 0 || name[strlen(name)-1] == '\r') {
/* check for not supported file names */
if (name[0] == 0) {
fprintf(stderr, "Unsupported name '%s' in file '%s'.\n", name, path_next);
exit(EXIT_FAILURE);
}