aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/fs_download.c4
-rw-r--r--src/fs/fs_file_information.c10
-rw-r--r--src/fs/fs_unindex.c2
-rw-r--r--src/fs/gnunet-directory.c2
-rw-r--r--src/fs/gnunet-helper-fs-publish.c10
-rw-r--r--src/fs/test_fs_download.c2
-rw-r--r--src/fs/test_fs_download_indexed.c2
-rw-r--r--src/fs/test_fs_download_persistence.c2
8 files changed, 21 insertions, 13 deletions
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index 0596d85e3..490beef5e 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -2068,7 +2068,7 @@ GNUNET_FS_download_start (struct GNUNET_FS_Handle *h,
2068 { 2068 {
2069 dc->filename = GNUNET_strdup (filename); 2069 dc->filename = GNUNET_strdup (filename);
2070 if (GNUNET_YES == GNUNET_DISK_file_test (filename)) 2070 if (GNUNET_YES == GNUNET_DISK_file_test (filename))
2071 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_size (filename, &dc->old_file_size, GNUNET_YES)); 2071 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_size (filename, &dc->old_file_size, GNUNET_YES, GNUNET_YES));
2072 } 2072 }
2073 if (GNUNET_FS_uri_test_loc (dc->uri)) 2073 if (GNUNET_FS_uri_test_loc (dc->uri))
2074 GNUNET_assert (GNUNET_OK == 2074 GNUNET_assert (GNUNET_OK ==
@@ -2178,7 +2178,7 @@ GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h,
2178 { 2178 {
2179 dc->filename = GNUNET_strdup (filename); 2179 dc->filename = GNUNET_strdup (filename);
2180 if (GNUNET_YES == GNUNET_DISK_file_test (filename)) 2180 if (GNUNET_YES == GNUNET_DISK_file_test (filename))
2181 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_size (filename, &dc->old_file_size, GNUNET_YES)); 2181 GNUNET_break (GNUNET_OK == GNUNET_DISK_file_size (filename, &dc->old_file_size, GNUNET_YES, GNUNET_YES));
2182 } 2182 }
2183 if (GNUNET_FS_uri_test_loc (dc->uri)) 2183 if (GNUNET_FS_uri_test_loc (dc->uri))
2184 GNUNET_assert (GNUNET_OK == 2184 GNUNET_assert (GNUNET_OK ==
diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c
index 85a076fee..806592784 100644
--- a/src/fs/fs_file_information.c
+++ b/src/fs/fs_file_information.c
@@ -107,7 +107,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
107 *bo) 107 *bo)
108{ 108{
109 struct FileInfo *fi; 109 struct FileInfo *fi;
110 struct stat sbuf; 110 uint64_t fsize;
111 struct GNUNET_FS_FileInformation *ret; 111 struct GNUNET_FS_FileInformation *ret;
112 const char *fn; 112 const char *fn;
113 const char *ss; 113 const char *ss;
@@ -116,7 +116,8 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
116 char fn_conv[MAX_PATH]; 116 char fn_conv[MAX_PATH];
117#endif 117#endif
118 118
119 if (0 != STAT (filename, &sbuf)) 119 /* FIXME: should includeSymLinks be GNUNET_NO or GNUNET_YES here? */
120 if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fsize, GNUNET_NO, GNUNET_YES))
120 { 121 {
121 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "stat", filename); 122 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "stat", filename);
122 return NULL; 123 return NULL;
@@ -129,7 +130,7 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
129 } 130 }
130 ret = 131 ret =
131 GNUNET_FS_file_information_create_from_reader (h, client_info, 132 GNUNET_FS_file_information_create_from_reader (h, client_info,
132 sbuf.st_size, 133 fsize,
133 &GNUNET_FS_data_reader_file_, 134 &GNUNET_FS_data_reader_file_,
134 fi, keywords, meta, 135 fi, keywords, meta,
135 do_index, bo); 136 do_index, bo);
@@ -145,6 +146,9 @@ GNUNET_FS_file_information_create_from_file (struct GNUNET_FS_Handle *h,
145#endif 146#endif
146 while (NULL != (ss = strstr (fn, DIR_SEPARATOR_STR))) 147 while (NULL != (ss = strstr (fn, DIR_SEPARATOR_STR)))
147 fn = ss + 1; 148 fn = ss + 1;
149/* FIXME: If we assume that on other platforms CRT is UTF-8-aware, then
150 * this should be changed to EXTRACTOR_METAFORMAT_UTF8
151 */
148#if !WINDOWS 152#if !WINDOWS
149 GNUNET_CONTAINER_meta_data_insert (ret->meta, "<gnunet>", 153 GNUNET_CONTAINER_meta_data_insert (ret->meta, "<gnunet>",
150 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME, 154 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME,
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c
index 3c2ef8f6f..bf619b75a 100644
--- a/src/fs/fs_unindex.c
+++ b/src/fs/fs_unindex.c
@@ -755,7 +755,7 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, const char *filename,
755 struct GNUNET_FS_ProgressInfo pi; 755 struct GNUNET_FS_ProgressInfo pi;
756 uint64_t size; 756 uint64_t size;
757 757
758 if (GNUNET_OK != GNUNET_DISK_file_size (filename, &size, GNUNET_YES)) 758 if (GNUNET_OK != GNUNET_DISK_file_size (filename, &size, GNUNET_YES, GNUNET_YES))
759 return NULL; 759 return NULL;
760 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_UnindexContext)); 760 ret = GNUNET_malloc (sizeof (struct GNUNET_FS_UnindexContext));
761 ret->h = h; 761 ret->h = h;
diff --git a/src/fs/gnunet-directory.c b/src/fs/gnunet-directory.c
index 0721ea90e..c722f57ff 100644
--- a/src/fs/gnunet-directory.c
+++ b/src/fs/gnunet-directory.c
@@ -136,7 +136,7 @@ run (void *cls, char *const *args, const char *cfgfile,
136 i = 0; 136 i = 0;
137 while (NULL != (filename = args[i++])) 137 while (NULL != (filename = args[i++]))
138 { 138 {
139 if ((GNUNET_OK != GNUNET_DISK_file_size (filename, &size, GNUNET_YES)) || 139 if ((GNUNET_OK != GNUNET_DISK_file_size (filename, &size, GNUNET_YES, GNUNET_YES)) ||
140 (NULL == 140 (NULL ==
141 (h = 141 (h =
142 GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, 142 GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
diff --git a/src/fs/gnunet-helper-fs-publish.c b/src/fs/gnunet-helper-fs-publish.c
index 4f7046408..4bb77fa22 100644
--- a/src/fs/gnunet-helper-fs-publish.c
+++ b/src/fs/gnunet-helper-fs-publish.c
@@ -69,7 +69,8 @@ struct ScanTreeNode
69 char *filename; 69 char *filename;
70 70
71 /** 71 /**
72 * Size of the file (if it is a file), in bytes 72 * Size of the file (if it is a file), in bytes.
73 * At the moment it is set to 0 for directories.
73 */ 74 */
74 uint64_t file_size; 75 uint64_t file_size;
75 76
@@ -275,8 +276,11 @@ preprocess_file (const char *filename,
275{ 276{
276 struct ScanTreeNode *item; 277 struct ScanTreeNode *item;
277 struct stat sbuf; 278 struct stat sbuf;
279 uint64_t fsize = 0;
278 280
279 if (0 != STAT (filename, &sbuf)) 281 if ((0 != STAT (filename, &sbuf)) ||
282 ((!S_ISDIR (sbuf.st_mode)) && (GNUNET_OK != GNUNET_DISK_file_size (
283 filename, &fsize, GNUNET_NO, GNUNET_YES))))
280 { 284 {
281 /* If the file doesn't exist (or is not stat-able for any other reason) 285 /* If the file doesn't exist (or is not stat-able for any other reason)
282 skip it (but report it), but do continue. */ 286 skip it (but report it), but do continue. */
@@ -297,7 +301,7 @@ preprocess_file (const char *filename,
297 item = GNUNET_malloc (sizeof (struct ScanTreeNode)); 301 item = GNUNET_malloc (sizeof (struct ScanTreeNode));
298 item->filename = GNUNET_strdup (filename); 302 item->filename = GNUNET_strdup (filename);
299 item->is_directory = (S_ISDIR (sbuf.st_mode)) ? GNUNET_YES : GNUNET_NO; 303 item->is_directory = (S_ISDIR (sbuf.st_mode)) ? GNUNET_YES : GNUNET_NO;
300 item->file_size = (uint64_t) sbuf.st_size; 304 item->file_size = fsize;
301 if (item->is_directory == GNUNET_YES) 305 if (item->is_directory == GNUNET_YES)
302 { 306 {
303 struct RecursionContext rc; 307 struct RecursionContext rc;
diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c
index 570eab909..198a8154e 100644
--- a/src/fs/test_fs_download.c
+++ b/src/fs/test_fs_download.c
@@ -118,7 +118,7 @@ abort_download_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
118 GNUNET_FS_download_stop (download, GNUNET_YES); 118 GNUNET_FS_download_stop (download, GNUNET_YES);
119 download = NULL; 119 download = NULL;
120 } 120 }
121 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES)); 121 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES, GNUNET_NO));
122 GNUNET_assert (size == FILESIZE); 122 GNUNET_assert (size == FILESIZE);
123 GNUNET_DISK_directory_remove (fn); 123 GNUNET_DISK_directory_remove (fn);
124 GNUNET_free (fn); 124 GNUNET_free (fn);
diff --git a/src/fs/test_fs_download_indexed.c b/src/fs/test_fs_download_indexed.c
index e8504f175..c00b9e717 100644
--- a/src/fs/test_fs_download_indexed.c
+++ b/src/fs/test_fs_download_indexed.c
@@ -119,7 +119,7 @@ abort_download_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
119 GNUNET_FS_download_stop (download, GNUNET_YES); 119 GNUNET_FS_download_stop (download, GNUNET_YES);
120 download = NULL; 120 download = NULL;
121 } 121 }
122 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES)); 122 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES, GNUNET_NO));
123 GNUNET_assert (size == FILESIZE); 123 GNUNET_assert (size == FILESIZE);
124 GNUNET_DISK_directory_remove (fn); 124 GNUNET_DISK_directory_remove (fn);
125 GNUNET_free (fn); 125 GNUNET_free (fn);
diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c
index bcb1c54b6..3a6d9553e 100644
--- a/src/fs/test_fs_download_persistence.c
+++ b/src/fs/test_fs_download_persistence.c
@@ -113,7 +113,7 @@ abort_download_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
113 GNUNET_FS_download_stop (download, GNUNET_YES); 113 GNUNET_FS_download_stop (download, GNUNET_YES);
114 download = NULL; 114 download = NULL;
115 } 115 }
116 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES)); 116 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES, GNUNET_NO));
117 GNUNET_assert (size == FILESIZE); 117 GNUNET_assert (size == FILESIZE);
118 GNUNET_DISK_directory_remove (fn); 118 GNUNET_DISK_directory_remove (fn);
119 GNUNET_free (fn); 119 GNUNET_free (fn);