diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-01-24 13:40:47 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-01-24 13:40:47 +0000 |
commit | f3fd2bc175ff3bee8680106782ab01e8b69c7724 (patch) | |
tree | ca69cbc7a4eb8a7cc982c74120d05db283a90cc8 /src | |
parent | 41d967a58fdf9df3b462980a3172ce1cb90cf334 (diff) | |
download | gnunet-f3fd2bc175ff3bee8680106782ab01e8b69c7724.tar.gz gnunet-f3fd2bc175ff3bee8680106782ab01e8b69c7724.zip |
append / to directory names (and remove later...)
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/fs_download.c | 62 | ||||
-rw-r--r-- | src/fs/fs_file_information.c | 10 | ||||
-rwxr-xr-x | src/fs/test_gnunet_fs_rec.py.in | 16 |
3 files changed, 22 insertions, 66 deletions
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index d001144f6..96ad797bf 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c | |||
@@ -902,6 +902,7 @@ trigger_recursive_download (void *cls, | |||
902 | char *dn; | 902 | char *dn; |
903 | char *pos; | 903 | char *pos; |
904 | char *full_name; | 904 | char *full_name; |
905 | char *sfn; | ||
905 | 906 | ||
906 | if (NULL == uri) | 907 | if (NULL == uri) |
907 | return; /* entry for the directory itself */ | 908 | return; /* entry for the directory itself */ |
@@ -965,6 +966,10 @@ trigger_recursive_download (void *cls, | |||
965 | (NULL != | 966 | (NULL != |
966 | strstr (dn + strlen(dn) - strlen(GNUNET_FS_DIRECTORY_EXT), | 967 | strstr (dn + strlen(dn) - strlen(GNUNET_FS_DIRECTORY_EXT), |
967 | GNUNET_FS_DIRECTORY_EXT)) ); | 968 | GNUNET_FS_DIRECTORY_EXT)) ); |
969 | sfn = GNUNET_strdup (filename); | ||
970 | while ( (strlen (sfn) > 0) && | ||
971 | (filename[strlen(sfn)-1] == '/') ) | ||
972 | sfn[strlen(sfn)-1] = '\0'; | ||
968 | if ( (strlen (dn) >= strlen (GNUNET_FS_DIRECTORY_EXT)) && | 973 | if ( (strlen (dn) >= strlen (GNUNET_FS_DIRECTORY_EXT)) && |
969 | (NULL != | 974 | (NULL != |
970 | strstr (dn + strlen(dn) - strlen(GNUNET_FS_DIRECTORY_EXT), | 975 | strstr (dn + strlen(dn) - strlen(GNUNET_FS_DIRECTORY_EXT), |
@@ -980,7 +985,7 @@ trigger_recursive_download (void *cls, | |||
980 | "%s%s%s%s", | 985 | "%s%s%s%s", |
981 | dn, | 986 | dn, |
982 | DIR_SEPARATOR_STR, | 987 | DIR_SEPARATOR_STR, |
983 | filename, | 988 | sfn, |
984 | GNUNET_FS_DIRECTORY_EXT); | 989 | GNUNET_FS_DIRECTORY_EXT); |
985 | } | 990 | } |
986 | else | 991 | else |
@@ -989,7 +994,7 @@ trigger_recursive_download (void *cls, | |||
989 | "%s%s%s", | 994 | "%s%s%s", |
990 | dn, | 995 | dn, |
991 | DIR_SEPARATOR_STR, | 996 | DIR_SEPARATOR_STR, |
992 | filename); | 997 | sfn); |
993 | } | 998 | } |
994 | GNUNET_free (dn); | 999 | GNUNET_free (dn); |
995 | } | 1000 | } |
@@ -1006,59 +1011,6 @@ trigger_recursive_download (void *cls, | |||
1006 | } | 1011 | } |
1007 | 1012 | ||
1008 | temp_name = NULL; | 1013 | temp_name = NULL; |
1009 | #if 0 | ||
1010 | if (data != NULL) | ||
1011 | { | ||
1012 | if (GNUNET_FS_uri_chk_get_file_size (uri) == length) | ||
1013 | { | ||
1014 | if (full_name == NULL) | ||
1015 | { | ||
1016 | temp_name = GNUNET_DISK_mktemp ("gnunet-download-trd"); | ||
1017 | real_name = temp_name; | ||
1018 | } | ||
1019 | else | ||
1020 | { | ||
1021 | real_name = full_name; | ||
1022 | } | ||
1023 | /* write to disk, then trigger normal download which will instantly progress to completion */ | ||
1024 | fh = GNUNET_DISK_file_open (real_name, | ||
1025 | GNUNET_DISK_OPEN_WRITE | GNUNET_DISK_OPEN_TRUNCATE | GNUNET_DISK_OPEN_CREATE, | ||
1026 | GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE); | ||
1027 | if (fh == NULL) | ||
1028 | { | ||
1029 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
1030 | "open", | ||
1031 | real_name); | ||
1032 | GNUNET_free (full_name); | ||
1033 | GNUNET_free_non_null (fn); | ||
1034 | return; | ||
1035 | } | ||
1036 | if (length != | ||
1037 | GNUNET_DISK_file_write (fh, | ||
1038 | data, | ||
1039 | length)) | ||
1040 | { | ||
1041 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | ||
1042 | "write", | ||
1043 | full_name); | ||
1044 | } | ||
1045 | #if DEBUG_DOWNLOAD | ||
1046 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1047 | "Wrote %llu bytes of plaintext from meta data to `%s' for validation\n", | ||
1048 | (unsigned long long) length, | ||
1049 | real_name); | ||
1050 | #endif | ||
1051 | GNUNET_DISK_file_close (fh); | ||
1052 | } | ||
1053 | else | ||
1054 | { | ||
1055 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1056 | _("Length mismatch between supplied plaintext and expected file size (%llu != %llu)\n"), | ||
1057 | (unsigned long long) GNUNET_FS_uri_chk_get_file_size (uri), | ||
1058 | (unsigned long long) length); | ||
1059 | } | ||
1060 | } | ||
1061 | #endif | ||
1062 | #if DEBUG_DOWNLOAD | 1014 | #if DEBUG_DOWNLOAD |
1063 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1015 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1064 | "Triggering recursive download of size %llu with %u bytes MD\n", | 1016 | "Triggering recursive download of size %llu with %u bytes MD\n", |
diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c index e0b048843..2ae708e59 100644 --- a/src/fs/fs_file_information.c +++ b/src/fs/fs_file_information.c | |||
@@ -422,7 +422,6 @@ dir_scan_cb (void *cls, | |||
422 | GNUNET_FS_meta_data_extract_from_file (meta, | 422 | GNUNET_FS_meta_data_extract_from_file (meta, |
423 | filename, | 423 | filename, |
424 | dsc->extractors); | 424 | dsc->extractors); |
425 | // FIXME: remove path from filename in metadata! | ||
426 | keywords = GNUNET_FS_uri_ksk_create_from_meta_data (meta); | 425 | keywords = GNUNET_FS_uri_ksk_create_from_meta_data (meta); |
427 | ksk_uri = GNUNET_FS_uri_ksk_canonicalize (keywords); | 426 | ksk_uri = GNUNET_FS_uri_ksk_canonicalize (keywords); |
428 | fi = GNUNET_FS_file_information_create_from_file (dsc->h, | 427 | fi = GNUNET_FS_file_information_create_from_file (dsc->h, |
@@ -582,6 +581,7 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h, | |||
582 | struct GNUNET_CONTAINER_MetaData *meta; | 581 | struct GNUNET_CONTAINER_MetaData *meta; |
583 | const char *fn; | 582 | const char *fn; |
584 | const char *ss; | 583 | const char *ss; |
584 | char *dn; | ||
585 | 585 | ||
586 | dc.entries = NULL; | 586 | dc.entries = NULL; |
587 | meta = GNUNET_CONTAINER_meta_data_create (); | 587 | meta = GNUNET_CONTAINER_meta_data_create (); |
@@ -617,13 +617,17 @@ GNUNET_FS_file_information_create_from_directory (struct GNUNET_FS_Handle *h, | |||
617 | DIR_SEPARATOR_STR))) && | 617 | DIR_SEPARATOR_STR))) && |
618 | (strlen (ss) > 1) ) | 618 | (strlen (ss) > 1) ) |
619 | fn = ss + 1; | 619 | fn = ss + 1; |
620 | GNUNET_asprintf (&dn, | ||
621 | "%s/", | ||
622 | fn); | ||
620 | GNUNET_CONTAINER_meta_data_insert (ret->meta, | 623 | GNUNET_CONTAINER_meta_data_insert (ret->meta, |
621 | "<gnunet>", | 624 | "<gnunet>", |
622 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, | 625 | EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, |
623 | EXTRACTOR_METAFORMAT_C_STRING, | 626 | EXTRACTOR_METAFORMAT_C_STRING, |
624 | "text/plain", | 627 | "text/plain", |
625 | fn, | 628 | dn, |
626 | strlen (fn) + 1); | 629 | strlen (dn) + 1); |
630 | GNUNET_free (dn); | ||
627 | ret->filename = GNUNET_strdup (filename); | 631 | ret->filename = GNUNET_strdup (filename); |
628 | return ret; | 632 | return ret; |
629 | } | 633 | } |
diff --git a/src/fs/test_gnunet_fs_rec.py.in b/src/fs/test_gnunet_fs_rec.py.in index a9c2b9c0e..3c990b35b 100755 --- a/src/fs/test_gnunet_fs_rec.py.in +++ b/src/fs/test_gnunet_fs_rec.py.in | |||
@@ -29,19 +29,19 @@ os.system ('tar xfz test_gnunet_fs_rec_data.tgz') | |||
29 | try: | 29 | try: |
30 | pub = pexpect.spawn ('gnunet-publish -c test_gnunet_fs_rec_data.conf -d -k testdir dir/') | 30 | pub = pexpect.spawn ('gnunet-publish -c test_gnunet_fs_rec_data.conf -d -k testdir dir/') |
31 | pub.expect ('Publishing `dir/\' done.\r') | 31 | pub.expect ('Publishing `dir/\' done.\r') |
32 | pub.expect ("URI is `gnunet://fs/chk/CQI091BQ15LLC2NO5RQM2LP95D8I0ONKDFT912V8CMH3BIPDUSDKG3JL07V9E89JPJ0CG5JE9EAQLC1Q6I0VF9L8M86MO0K3DG7HA2O.NVIUL6B7AT6TIUVOV0JLIQ3LLSS3TRLCVAISDS47V0KVHN22TJ9H9247HQNA8T3KK1J32QJ65312DUQPA2EBQPNII279BU0MKJEB94G.20181'.") | 32 | pub.expect ("URI is `gnunet://fs/chk/M2I80IUI2DM4L6G93KL15AHAO7MIMS5JKP1L3LQFVN50CT7AKRQDSF594BC9TD97JJIT3COF6B5O524CMIOG9EJO8UK1560M54JRI70.GBRE5M4QJ7NA0QIN88FMSC78NNOQMVT5DH8FP37OIR5SGGHFEB9ESDNBRKT9PFE9N2GOI81UN8GGBR6KH9GRTV1T04JFSJURF2U0VE8.20182'.") |
33 | pub.expect (pexpect.EOF) | 33 | pub.expect (pexpect.EOF) |
34 | 34 | ||
35 | down = pexpect.spawn ('gnunet-download -c test_gnunet_fs_rec_data.conf -R -o rdir.gnd gnunet://fs/chk/CQI091BQ15LLC2NO5RQM2LP95D8I0ONKDFT912V8CMH3BIPDUSDKG3JL07V9E89JPJ0CG5JE9EAQLC1Q6I0VF9L8M86MO0K3DG7HA2O.NVIUL6B7AT6TIUVOV0JLIQ3LLSS3TRLCVAISDS47V0KVHN22TJ9H9247HQNA8T3KK1J32QJ65312DUQPA2EBQPNII279BU0MKJEB94G.20181') | 35 | down = pexpect.spawn ('gnunet-download -c test_gnunet_fs_rec_data.conf -R -o rdir.gnd gnunet://fs/chk/M2I80IUI2DM4L6G93KL15AHAO7MIMS5JKP1L3LQFVN50CT7AKRQDSF594BC9TD97JJIT3COF6B5O524CMIOG9EJO8UK1560M54JRI70.GBRE5M4QJ7NA0QIN88FMSC78NNOQMVT5DH8FP37OIR5SGGHFEB9ESDNBRKT9PFE9N2GOI81UN8GGBR6KH9GRTV1T04JFSJURF2U0VE8.20182') |
36 | down.expect (re.compile ("Downloading `rdir.gnd\' done \(.*\).\r")); | 36 | down.expect (re.compile ("Downloading `rdir.gnd\' done \(.*\).\r")); |
37 | down.expect (pexpect.EOF); | 37 | down.expect (pexpect.EOF); |
38 | 38 | ||
39 | # dir = pexpect.spawn ('gnunet-directory -c test_gnunet_fs_rec_data.conf rdir/a.gnd') | 39 | dir = pexpect.spawn ('gnunet-directory -c test_gnunet_fs_rec_data.conf rdir/a.gnd') |
40 | # dir.expect (re.compile ("Directory `a' summary:")); | 40 | dir.expect (re.compile ("Directory `a/' meta data:")); |
41 | # dir.expect (re.compile (" *mimetype: application/gnunet-directory")); | 41 | dir.expect (re.compile ("Directory `a/' contents:")); |
42 | # dir.expect (re.compile ("COPYING (.*)")); | 42 | dir.expect (re.compile ("COPYING (.*)")); |
43 | # dir.expect (re.compile ("INSTALL (.*)")); | 43 | dir.expect (re.compile ("INSTALL (.*)")); |
44 | # dir.expect (pexpect.EOF) | 44 | dir.expect (pexpect.EOF) |
45 | 45 | ||
46 | os.system ('rm -r rdir/b.gnd rdir/a.gnd') | 46 | os.system ('rm -r rdir/b.gnd rdir/a.gnd') |
47 | if (0 != os.system ("diff -r dir rdir")): | 47 | if (0 != os.system ("diff -r dir rdir")): |