int32_t ranking, const char *ns_name)
{
char *fn;
- int ret;
+ struct GNUNET_BIO_WriteHandle *fileW;
+
fn = get_data_filename (cfg, PS_METADATA_DIR, nsid);
GNUNET_assert (fn != NULL);
- struct GNUNET_BIO_WriteHandle *fileW;
fileW = GNUNET_BIO_write_open(fn);
- if((NULL != fileW)&&
- (GNUNET_OK == GNUNET_BIO_write_int32(fileW, ranking))&&
- (GNUNET_OK == GNUNET_BIO_write_string(fileW, ns_name))&&
- (GNUNET_OK == GNUNET_BIO_write_meta_data(fileW, meta))&&
- (GNUNET_OK == GNUNET_BIO_write_close(fileW)))
- ret = GNUNET_OK;
- else
- ret = GNUNET_SYSERR;
+ if (NULL != fileW)
+ {
+ if ( (GNUNET_OK != GNUNET_BIO_write_int32(fileW, ranking)) ||
+ (GNUNET_OK != GNUNET_BIO_write_string(fileW, ns_name)) ||
+ (GNUNET_OK != GNUNET_BIO_write_meta_data(fileW, meta)) )
+ {
+ GNUNET_BIO_write_close(fileW);
+ GNUNET_break (GNUNET_OK == GNUNET_DISK_directory_remove (fileW));
+ GNUNET_free (fn);
+ return;
+ }
+ if (GNUNET_OK != GNUNET_BIO_write_close(fileW))
+ {
+ GNUNET_break (GNUNET_OK == GNUNET_DISK_directory_remove (fileW));
+ GNUNET_free (fn);
+ return;
+ }
+ }
GNUNET_free (fn);
/* create entry for pseudonym name in names */
GNUNET_free_non_null (GNUNET_PSEUDONYM_id_to_name (cfg, nsid));