Better checks for non-existent inodes.
[bluesky.git] / bluesky / s3store.c
index 1a9e6b9..2e1eb17 100644 (file)
@@ -61,6 +61,7 @@ static void s3store_destroy(gpointer store)
 }
 
 struct get_info {
+    int success;
     GString *buf;
 };
 
@@ -98,8 +99,15 @@ static void s3store_response_callback(S3Status status,
                                const S3ErrorDetails *errorDetails,
                                void *callbackData)
 {
+    struct get_info *info = (struct get_info *)callbackData;
+
     g_print("S3 operation complete, status=%s, now=%ld\n",
             S3_get_status_name(status), bluesky_now_hires());
+
+    if (status == 0) {
+        info->success = 1;
+    }
+
     if (errorDetails != NULL) {
         g_print("  Error message: %s\n", errorDetails->message);
     }
@@ -111,6 +119,7 @@ static BlueSkyRCStr *s3store_get(gpointer s, const gchar *key)
 
     struct get_info info;
     info.buf = g_string_new("");
+    info.success = 0;
 
     struct S3GetObjectHandler handler;
     handler.responseHandler.propertiesCallback = s3store_properties_callback;
@@ -121,6 +130,11 @@ static BlueSkyRCStr *s3store_get(gpointer s, const gchar *key)
     S3_get_object(&store->bucket, key, NULL, 0, 0, NULL,
                   &handler, &info);
 
+    if (!info.success) {
+        g_string_free(info.buf, TRUE);
+        return NULL;
+    }
+
     BlueSkyRCStr *raw, *decrypted;
     raw = bluesky_string_new_from_gstring(info.buf);
     decrypted = bluesky_crypt_decrypt(raw, store->encryption_key);