[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r14216 - gnunet/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r14216 - gnunet/src/fs |
Date: |
Thu, 20 Jan 2011 16:19:32 +0100 |
Author: grothoff
Date: 2011-01-20 16:19:32 +0100 (Thu, 20 Jan 2011)
New Revision: 14216
Modified:
gnunet/src/fs/fs_download.c
Log:
fix
Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2011-01-20 15:16:47 UTC (rev 14215)
+++ gnunet/src/fs/fs_download.c 2011-01-20 15:19:32 UTC (rev 14216)
@@ -290,7 +290,9 @@
}
#if DEBUG_DOWNLOAD
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Matching block already present, no need for download!\n");
+ "Matching block for `%s' at offset %llu already present, no need
for download!\n",
+ dc->filename,
+ (unsigned long long) dr->offset);
#endif
/* already got it! */
prc.dc = dc;
@@ -470,7 +472,7 @@
unsigned int i;
char enc[DBLOCK_SIZE];
struct ContentHashKey chks[CHK_PER_INODE];
- struct ContentHashKey chk;
+ struct ContentHashKey in_chk;
struct GNUNET_CRYPTO_AesSessionKey sk;
struct GNUNET_CRYPTO_AesInitializationVector iv;
size_t dlen;
@@ -478,7 +480,11 @@
struct GNUNET_DISK_FileHandle *fh;
int complete;
const char *fn;
+ const char *odata;
+ size_t odata_len;
+ odata = data;
+ odata_len = data_len;
if (BRS_DOWNLOAD_UP == dr->state)
return;
if (dr->depth > 0)
@@ -492,6 +498,8 @@
data, data_len);
if (drc->state != BRS_RECONSTRUCT_META_UP)
complete = GNUNET_NO;
+ else
+ chks[i] = drc->chk;
}
if (GNUNET_YES != complete)
return;
@@ -507,9 +515,9 @@
}
GNUNET_CRYPTO_hash (&data[dr->offset],
dlen,
- &chk.key);
- GNUNET_CRYPTO_hash_to_aes_key (&chk.key, &sk, &iv);
- if (-1 == GNUNET_CRYPTO_aes_encrypt (data, dlen,
+ &in_chk.key);
+ GNUNET_CRYPTO_hash_to_aes_key (&in_chk.key, &sk, &iv);
+ if (-1 == GNUNET_CRYPTO_aes_encrypt (&data[dr->offset], dlen,
&sk,
&iv,
enc))
@@ -517,15 +525,15 @@
GNUNET_break (0);
return;
}
- GNUNET_CRYPTO_hash (enc, dlen, &chk.query);
+ GNUNET_CRYPTO_hash (enc, dlen, &in_chk.query);
switch (dr->state)
{
case BRS_INIT:
- dr->chk = chk;
+ dr->chk = in_chk;
dr->state = BRS_RECONSTRUCT_META_UP;
break;
case BRS_CHK_SET:
- if (0 != memcmp (&chk,
+ if (0 != memcmp (&in_chk,
&dr->chk,
sizeof (struct ContentHashKey)))
{
@@ -562,8 +570,8 @@
}
if (data_len !=
GNUNET_DISK_file_write (fh,
- data,
- data_len))
+ odata,
+ odata_len))
{
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
"write",
@@ -589,6 +597,11 @@
pi.value.download.specifics.progress.data_len = dlen;
pi.value.download.specifics.progress.depth = 0;
GNUNET_FS_download_make_status_ (&pi, dc);
+ if (0 != truncate (dc->filename,
+ GNUNET_ntohll (dc->uri->data.chk.file_length)))
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
+ "truncate",
+ dc->filename);
check_completed (dc);
break;
default:
@@ -630,6 +643,11 @@
if (type != EXTRACTOR_METATYPE_GNUNET_FULL_DATA)
return 0;
+#if DEBUG_DOWNLOAD
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Found %u bytes of FD!\n",
+ (unsigned int) data_len);
+#endif
if (GNUNET_FS_uri_chk_get_file_size (dc->uri) != data_len)
{
GNUNET_break_op (0);
@@ -734,7 +752,7 @@
return; /* mismatch */
if (GNUNET_OK !=
encrypt_existing_match (dc,
- chk,
+ &dr->chk,
dr,
block,
len,
@@ -1019,6 +1037,12 @@
}
GNUNET_DISK_file_close (fh);
}
+#if DEBUG_DOWNLOAD
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Triggering recursive download of size %llu with %u bytes MD\n",
+ (unsigned long long) GNUNET_FS_uri_chk_get_file_size (uri),
+ (unsigned int) GNUNET_CONTAINER_meta_data_get_serialized_size
(meta));
+#endif
GNUNET_FS_download_start (dc->h,
uri,
meta,
@@ -1116,10 +1140,9 @@
goto signal_error;
}
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (dc->active,
- &prc->query,
- dr));
+ (void) GNUNET_CONTAINER_multihashmap_remove (dc->active,
+ &prc->query,
+ dr);
if (GNUNET_YES == dr->is_pending)
{
GNUNET_CONTAINER_DLL_remove (dc->pending_head,
@@ -2064,8 +2087,15 @@
}
}
/* attempt reconstruction from meta data */
- if (GNUNET_FS_uri_chk_get_file_size (dc->uri) <= MAX_INLINE_SIZE)
+ if ( (GNUNET_FS_uri_chk_get_file_size (dc->uri) <= MAX_INLINE_SIZE) &&
+ (NULL != dc->meta) )
{
+#if DEBUG_DOWNLOAD
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Trying to find embedded meta data for download of size %llu
with %u bytes MD\n",
+ (unsigned long long) GNUNET_FS_uri_chk_get_file_size
(dc->uri),
+ (unsigned int) GNUNET_CONTAINER_meta_data_get_serialized_size
(dc->meta));
+#endif
GNUNET_CONTAINER_meta_data_iterate (dc->meta,
&match_full_data,
dc);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r14216 - gnunet/src/fs,
gnunet <=