src/backup/chunk_store.rs: avoid create/unlink race

This commit is contained in:
Dietmar Maurer 2019-03-31 10:03:01 +02:00
parent c374f05499
commit 15a77c4c2e

View File

@ -266,7 +266,8 @@ impl ChunkStore {
continue;
}
let filename = entry.file_name();
let lock = self.mutex.lock();
if let Ok(stat) = fstatat(dirfd, filename, nix::fcntl::AtFlags::AT_SYMLINK_NOFOLLOW) {
let age = now - stat.st_atime;
//println!("FOUND {} {:?}", age/(3600*24), filename);
@ -285,9 +286,9 @@ impl ChunkStore {
} else {
status.disk_chunks += 1;
status.disk_bytes += stat.st_size as usize;
}
}
drop(lock);
}
Ok(())
}