aboutsummaryrefslogtreecommitdiff
path: root/src/revocation/gnunet-revocation.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-12-19 18:43:38 +0100
committerChristian Grothoff <christian@grothoff.org>2020-12-19 18:43:38 +0100
commit3636ea628d051cf2ba7a9038c50528c561d0aeaa (patch)
tree87664b904950052e8b6997a371ed5ecb1ea4b310 /src/revocation/gnunet-revocation.c
parent74d7528e6bd53cf5acc939c63a5be74a001e5ce1 (diff)
downloadgnunet-3636ea628d051cf2ba7a9038c50528c561d0aeaa.tar.gz
gnunet-3636ea628d051cf2ba7a9038c50528c561d0aeaa.zip
change GNUNET_DISK_fn_write() to always do atomic writes and to NOT overwrite existing files; also change the return value to not return the size of the written file but GNUNET_OK on success, and integrate creating the directory if needed; breaks API, hence bumping libgnunetutil version
Diffstat (limited to 'src/revocation/gnunet-revocation.c')
-rw-r--r--src/revocation/gnunet-revocation.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/revocation/gnunet-revocation.c b/src/revocation/gnunet-revocation.c
index d59ea7c81..b5737158b 100644
--- a/src/revocation/gnunet-revocation.c
+++ b/src/revocation/gnunet-revocation.c
@@ -230,7 +230,7 @@ sync_pow ()
230{ 230{
231 size_t psize = GNUNET_REVOCATION_proof_get_size (proof_of_work); 231 size_t psize = GNUNET_REVOCATION_proof_get_size (proof_of_work);
232 if ((NULL != filename) && 232 if ((NULL != filename) &&
233 (psize != 233 (GNUNET_OK !=
234 GNUNET_DISK_fn_write (filename, 234 GNUNET_DISK_fn_write (filename,
235 proof_of_work, 235 proof_of_work,
236 psize, 236 psize,
@@ -280,14 +280,17 @@ calculate_pow (void *cls)
280 if (GNUNET_OK == GNUNET_REVOCATION_pow_round (ph)) 280 if (GNUNET_OK == GNUNET_REVOCATION_pow_round (ph))
281 { 281 {
282 psize = GNUNET_REVOCATION_proof_get_size (proof_of_work); 282 psize = GNUNET_REVOCATION_proof_get_size (proof_of_work);
283 if ((NULL != filename) && 283 if (NULL != filename)
284 (psize != 284 {
285 GNUNET_DISK_fn_write (filename, 285 (void) GNUNET_DISK_directory_remove (filename);
286 proof_of_work, 286 if (GNUNET_OK !=
287 psize, 287 GNUNET_DISK_fn_write (filename,
288 GNUNET_DISK_PERM_USER_READ 288 proof_of_work,
289 | GNUNET_DISK_PERM_USER_WRITE))) 289 psize,
290 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", filename); 290 GNUNET_DISK_PERM_USER_READ
291 | GNUNET_DISK_PERM_USER_WRITE))
292 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", filename);
293 }
291 if (perform) 294 if (perform)
292 { 295 {
293 perform_revocation (); 296 perform_revocation ();