Fix to the cleaner when writing out a new inode map.
[bluesky.git] / bluesky / log.c
index 2e5c920..6475b5d 100644 (file)
@@ -443,14 +443,16 @@ BlueSkyCacheFile *bluesky_cachefile_lookup(BlueSkyFS *fs,
             ftruncate(fd, 5 << 20);     // FIXME
             close(fd);
         }
-
-        // If the log file is stored in the cloud, we may need to fetch it
-        if (clouddir >= 0 && start_fetch)
-            cloudlog_fetch_start(map);
     } else {
         g_mutex_lock(map->lock);
     }
 
+
+    /* If the log file is stored in the cloud and has not been fully fetched,
+     * we may need to initiate a fetch now. */
+    if (clouddir >= 0 && start_fetch && !map->complete && !map->fetching)
+        cloudlog_fetch_start(map);
+
     g_mutex_unlock(log->mmap_lock);
     if (map != NULL)
         g_atomic_int_inc(&map->refcount);