summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-11-30 00:23:46 +0100
committerChristian Grothoff <christian@grothoff.org>2019-11-30 00:23:46 +0100
commit7f699113231130004c4535036f1de48edafe81aa (patch)
tree7516064627f1b310357667e223a5644e6d20ce8a
parent4df7d81cea4ce9ac714bb819ee661def6e0efb13 (diff)
downloadsync-7f699113231130004c4535036f1de48edafe81aa.tar.gz
sync-7f699113231130004c4535036f1de48edafe81aa.tar.bz2
sync-7f699113231130004c4535036f1de48edafe81aa.zip
only use prev hash if it succeeded
-rw-r--r--src/lib/test_sync_api.c13
-rw-r--r--src/lib/testing_api_cmd_backup_upload.c6
-rw-r--r--src/sync/sync-httpd_backup_post.c7
-rw-r--r--src/syncdb/plugin_syncdb_postgres.c13
4 files changed, 38 insertions, 1 deletions
diff --git a/src/lib/test_sync_api.c b/src/lib/test_sync_api.c
index cae8068..25cd08f 100644
--- a/src/lib/test_sync_api.c
+++ b/src/lib/test_sync_api.c
@@ -185,8 +185,10 @@ run (void *cls,
"create-reserve-1",
"EUR:5",
MHD_HTTP_OK),
+ /* Failed download: no backup exists */
SYNC_TESTING_cmd_backup_nx ("backup-download-nx",
sync_url),
+ /* Failed upload: need to pay */
SYNC_TESTING_cmd_backup_upload ("backup-upload-1",
sync_url,
NULL /* prev upload */,
@@ -194,11 +196,13 @@ run (void *cls,
MHD_HTTP_PAYMENT_REQUIRED,
"Test-1",
strlen ("Test-1")),
+ /* what would we have to pay? */
TALER_TESTING_cmd_proposal_lookup ("fetch-proposal",
merchant_url,
MHD_HTTP_OK,
"backup-upload-1",
NULL),
+ /* make the payment */
TALER_TESTING_cmd_pay ("pay-account",
merchant_url,
MHD_HTTP_OK,
@@ -207,6 +211,15 @@ run (void *cls,
"EUR:5",
"EUR:4.99", /* must match ANNUAL_FEE in config! */
"EUR:0.01"),
+ /* now upload should succeed */
+ SYNC_TESTING_cmd_backup_upload ("backup-upload-2",
+ sync_url,
+ "backup-upload-1",
+ SYNC_TESTING_UO_NONE,
+ MHD_HTTP_NO_CONTENT,
+ "Test-1",
+ strlen ("Test-1")),
+
TALER_TESTING_cmd_end ()
};
diff --git a/src/lib/testing_api_cmd_backup_upload.c b/src/lib/testing_api_cmd_backup_upload.c
index 6ed228a..bdbd374 100644
--- a/src/lib/testing_api_cmd_backup_upload.c
+++ b/src/lib/testing_api_cmd_backup_upload.c
@@ -186,6 +186,9 @@ backup_upload_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Order ID from Sync service is `%s'\n",
bus->payment_order_id);
+ memset (&bus->curr_hash,
+ 0,
+ sizeof (struct GNUNET_HashCode));
}
break;
case SYNC_US_CONFLICTING_BACKUP:
@@ -338,7 +341,8 @@ backup_upload_run (void *cls,
bus->uo = SYNC_upload (is->ctx,
bus->sync_url,
&bus->sync_priv,
- ( (NULL != bus->prev_upload) ||
+ ( ( (NULL != bus->prev_upload) &&
+ (0 != GNUNET_is_zero (&bus->prev_hash)) ) ||
(0 != (SYNC_TESTING_UO_PREV_HASH_WRONG
& bus->uopt)) )
? &bus->prev_hash
diff --git a/src/sync/sync-httpd_backup_post.c b/src/sync/sync-httpd_backup_post.c
index 6562b0e..f203691 100644
--- a/src/sync/sync-httpd_backup_post.c
+++ b/src/sync/sync-httpd_backup_post.c
@@ -824,6 +824,13 @@ sync_handler_backup_post (struct MHD_Connection *connection,
*upload_data_size = 0;
return MHD_YES;
}
+ else if ( (0 == bc->upload_off) &&
+ (0 != bc->upload_size) &&
+ (NULL == bc->resp) )
+ {
+ /* wait for upload */
+ return MHD_YES;
+ }
if (NULL != bc->resp)
{
int ret;
diff --git a/src/syncdb/plugin_syncdb_postgres.c b/src/syncdb/plugin_syncdb_postgres.c
index 61b192c..4273d75 100644
--- a/src/syncdb/plugin_syncdb_postgres.c
+++ b/src/syncdb/plugin_syncdb_postgres.c
@@ -1181,6 +1181,19 @@ libsync_plugin_db_postgres_init (void *cls)
GNUNET_free (pg);
return NULL;
}
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ "taler",
+ "CURRENCY",
+ &pg->currency))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "taler",
+ "CURRENCY");
+ GNUNET_PQ_disconnect (pg->conn);
+ GNUNET_free (pg);
+ return NULL;
+ }
plugin = GNUNET_new (struct SYNC_DatabasePlugin);
plugin->cls = pg;
plugin->drop_tables = &postgres_drop_tables;