X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=bluesky%2Flog.c;h=3fb9ef0aa232d807a7194e4bf9b3acc9e2629fe7;hb=e692553e85c46324aaeb36c6e737339ddae115a0;hp=89d4258fabae54a3cd901c904170e5675519b103;hpb=afc95f0ab2900a311802028f1b811867fa3c0c31;p=bluesky.git diff --git a/bluesky/log.c b/bluesky/log.c index 89d4258..3fb9ef0 100644 --- a/bluesky/log.c +++ b/bluesky/log.c @@ -413,6 +413,7 @@ BlueSkyCacheFile *bluesky_cachefile_lookup(BlueSkyFS *fs, g_mutex_lock(map->lock); map->cond = g_cond_new(); map->filename = g_strdup(logname); + map->log_dir = clouddir; map->log_seq = log_seq; map->log = log; g_atomic_int_set(&map->mapcount, 0); @@ -480,11 +481,16 @@ static void cloudlog_partial_fetch_start(BlueSkyCacheFile *cachefile, static void cloudlog_partial_fetch_complete(BlueSkyStoreAsync *async, BlueSkyCacheFile *cachefile) { - g_print("Partial fetch of %s from cloud complete, status = %d\n", + g_print("Fetch of %s from cloud complete, status = %d\n", async->key, async->result); g_mutex_lock(cachefile->lock); if (async->result >= 0) { + if (async->len == 0) { + g_print("Complete object was fetched.\n"); + cachefile->complete = TRUE; + } + /* Descrypt items fetched and write valid items out to the local log, * but only if they do not overlap existing objects. This will protect * against an attack by the cloud provider where one valid object is @@ -493,9 +499,11 @@ static void cloudlog_partial_fetch_complete(BlueSkyStoreAsync *async, BlueSkyRangeset *items = bluesky_rangeset_new(); int fd = openat(cachefile->log->dirfd, cachefile->filename, O_WRONLY); if (fd >= 0) { + gboolean allow_unauth; async->data = bluesky_string_dup(async->data); + allow_unauth = cachefile->log_dir == BLUESKY_CLOUD_DIR_CLEANER; bluesky_cloudlog_decrypt(async->data->data, async->data->len, - cachefile->fs->keys, items); + cachefile->fs->keys, items, allow_unauth); uint64_t item_offset = 0; while (TRUE) { const BlueSkyRangesetItem *item;