diff options
author | Nils Durner <durner@gnunet.org> | 2005-11-18 22:11:01 +0000 |
---|---|---|
committer | Nils Durner <durner@gnunet.org> | 2005-11-18 22:11:01 +0000 |
commit | 262b6068b27f22d50ed483b70e2908cbf14764ed (patch) | |
tree | 27fd0a13f24d73b2f8a0a2d7c5867126ae4d94b7 | |
parent | 530d11d892ccd7f6d72793c3043558f877b70dcd (diff) | |
download | gnunet-gtk-262b6068b27f22d50ed483b70e2908cbf14764ed.tar.gz gnunet-gtk-262b6068b27f22d50ed483b70e2908cbf14764ed.zip |
Check whether INCOMINGDIR and DOWNLOADDIR are the same (Mantis #973)
-rw-r--r-- | src/plugins/fs/download.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c index 7d1ab986..9fc0fe95 100644 --- a/src/plugins/fs/download.c +++ b/src/plugins/fs/download.c | |||
@@ -115,6 +115,7 @@ static void initiateDownload(GtkTreeModel * model, | |||
115 | char * pfx; | 115 | char * pfx; |
116 | char * lnk; | 116 | char * lnk; |
117 | char * fn; | 117 | char * fn; |
118 | char * inc; | ||
118 | DownloadList * list; | 119 | DownloadList * list; |
119 | GtkTreeIter iiter; | 120 | GtkTreeIter iiter; |
120 | GtkWidget * spin; | 121 | GtkWidget * spin; |
@@ -183,6 +184,27 @@ static void initiateDownload(GtkTreeModel * model, | |||
183 | if (name == NULL) | 184 | if (name == NULL) |
184 | name = filename; | 185 | name = filename; |
185 | 186 | ||
187 | fn = getFileName("FS", | ||
188 | "DOWNLOADDIR", | ||
189 | _("You must specify a directory in the configuration" | ||
190 | " in section `%s' under `%s'.")); | ||
191 | inc = getFileName("FS", | ||
192 | "INCOMINGDIR", | ||
193 | _("You must specify a directory in the configuration" | ||
194 | " in section `%s' under `%s'.")); | ||
195 | |||
196 | if (strcmp(fn, inc) == 0) { | ||
197 | LOG(LOG_ERROR, _("You must specify different directories in the " | ||
198 | "configuration in section `%s' under `%s' and `%s'."), | ||
199 | "FS", "DOWNLOADDIR", "INCOMINGDIR"); | ||
200 | |||
201 | FREE(filename); | ||
202 | FREENONNULL(fn); | ||
203 | FREENONNULL(inc); | ||
204 | |||
205 | return; | ||
206 | } | ||
207 | |||
186 | addLogEntry(_("Downloading `%s'"), name); | 208 | addLogEntry(_("Downloading `%s'"), name); |
187 | 209 | ||
188 | list = MALLOC(sizeof(DownloadList)); | 210 | list = MALLOC(sizeof(DownloadList)); |
@@ -194,10 +216,7 @@ static void initiateDownload(GtkTreeModel * model, | |||
194 | list->model = model; | 216 | list->model = model; |
195 | } | 217 | } |
196 | list->uri = ECRS_dupUri(uri); | 218 | list->uri = ECRS_dupUri(uri); |
197 | fn = getFileName("FS", | 219 | |
198 | "DOWNLOADDIR", | ||
199 | _("You must specify a directory in the configuration" | ||
200 | " in section `%s' under `%s'.")); | ||
201 | #ifdef WINDOWS | 220 | #ifdef WINDOWS |
202 | downDirLen = strlen(fn); | 221 | downDirLen = strlen(fn); |
203 | #endif | 222 | #endif |
@@ -243,17 +262,11 @@ static void initiateDownload(GtkTreeModel * model, | |||
243 | We truncate the hash here accordingly. */ | 262 | We truncate the hash here accordingly. */ |
244 | 263 | ||
245 | int diff; /* How much is INCOMINGDIR larger than DOWNLOADDIR */ | 264 | int diff; /* How much is INCOMINGDIR larger than DOWNLOADDIR */ |
246 | char *inc = getFileName("FS", | ||
247 | "INCOMINGDIR", | ||
248 | _("You must specify a directory in the configuration" | ||
249 | " in section `%s' under `%s'.")); | ||
250 | 265 | ||
251 | diff = downDirLen - strlen(inc); | 266 | diff = downDirLen - strlen(inc); |
252 | if (diff < 0) | 267 | if (diff < 0) |
253 | diff = 0; | 268 | diff = 0; |
254 | 269 | ||
255 | FREE(inc); | ||
256 | |||
257 | char *end = lnk + MAX_PATH - 5 - diff; /* 4 = ".lnk" */ | 270 | char *end = lnk + MAX_PATH - 5 - diff; /* 4 = ".lnk" */ |
258 | 271 | ||
259 | *end = 0; | 272 | *end = 0; |
@@ -264,6 +277,9 @@ static void initiateDownload(GtkTreeModel * model, | |||
264 | } | 277 | } |
265 | } | 278 | } |
266 | #endif | 279 | #endif |
280 | |||
281 | FREENONNULL(inc); | ||
282 | |||
267 | if (0 != STAT(pfx, | 283 | if (0 != STAT(pfx, |
268 | &sbuf)) { | 284 | &sbuf)) { |
269 | if (0 != SYMLINK(lnk, pfx)) | 285 | if (0 != SYMLINK(lnk, pfx)) |