From b2635763a163d2672e6a00cf144c83668ec13d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20PORTAY?= Date: Thu, 20 Jun 2019 10:56:02 -0400 Subject: [PATCH] calocation: fix ESTALE when extracting to regular file There is an issue when an archive is extracted to a regular file that exists already. # Extract the archive.caibx to dest.bin (dest.bin does not exist yet) $ casync extract http://localhost/archive.caibx dest.bin # Extract the archive.caibx to existing dest.bin $ casync extract http://localhost/archive.caibx dest.bin --log-level debug --verbose Acquiring http://localhost/archive.caibx... Setting min/avg/max chunk size: 16384 / 65536 / 262144 Failed to run decoder step: Stale file handle Failed to run synchronizer: Stale file handle The error raised is a difference in the modify time. In the case of the destination regular file exists (ie. the second call in the example above), the path goes to several fallocate/write calls that causes the modification time to be updated and leads to that error. This commit drops the check for the modification time. --- src/calocation.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/calocation.c b/src/calocation.c index 2ab8d946..743ab6a6 100644 --- a/src/calocation.c +++ b/src/calocation.c @@ -572,7 +572,6 @@ int ca_location_open(CaLocation *l) { if (l->mtime != UINT64_MAX) { struct stat st; - uint64_t n; /* Ensure inode, mtime and generation still match */ @@ -582,10 +581,6 @@ int ca_location_open(CaLocation *l) { if (st.st_ino != l->inode) return -ESTALE; - n = MAX(timespec_to_nsec(st.st_mtim), timespec_to_nsec(st.st_ctim)); - if (l->mtime != n) - return -ESTALE; - if (l->generation_valid) { int v;