[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6882 - GNUnet/src/applications/fs/fsui
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6882 - GNUnet/src/applications/fs/fsui |
Date: |
Sun, 25 May 2008 20:59:45 -0600 (MDT) |
Author: grothoff
Date: 2008-05-25 20:59:45 -0600 (Sun, 25 May 2008)
New Revision: 6882
Modified:
GNUnet/src/applications/fs/fsui/download.c
Log:
fixing Mantis #1337 -- recursive downloads
Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c 2008-05-26 02:59:26 UTC (rev
6881)
+++ GNUnet/src/applications/fs/fsui/download.c 2008-05-26 02:59:45 UTC (rev
6882)
@@ -280,7 +280,8 @@
if ((lastBlockOffset == 0) && (dl->is_directory == GNUNET_SYSERR))
{
/* check if this is a directory */
- if ((lastBlockSize > strlen (GNUNET_DIRECTORY_MAGIC)) &&
+ if ((dl->filename[strlen(dl->filename)-1] == '/') &&
+ (lastBlockSize > strlen (GNUNET_DIRECTORY_MAGIC)) &&
(0 == strncmp (GNUNET_DIRECTORY_MAGIC,
lastBlock, strlen (GNUNET_DIRECTORY_MAGIC))))
dl->is_directory = GNUNET_YES;
@@ -290,23 +291,10 @@
if (totalBytes == completedBytes)
{
dl->state = GNUNET_FSUI_COMPLETED;
- event.type = GNUNET_FSUI_download_completed;
- event.data.DownloadCompleted.dc.pos = dl;
- event.data.DownloadCompleted.dc.cctx = dl->cctx;
- event.data.DownloadCompleted.dc.ppos =
- dl->parent == &dl->ctx->activeDownloads ? NULL : dl->parent;
- event.data.DownloadCompleted.dc.pcctx = dl->parent->cctx;
- event.data.DownloadCompleted.dc.spos = dl->search;
- event.data.DownloadCompleted.dc.sctx =
- dl->search == NULL ? NULL : dl->search->cctx;
- event.data.DownloadCompleted.total = dl->total;
- event.data.DownloadCompleted.filename = dl->filename;
- event.data.DownloadCompleted.uri = dl->fi.uri;
GNUNET_URITRACK_add_state (dl->ctx->ectx,
dl->ctx->cfg,
dl->fi.uri,
GNUNET_URITRACK_DOWNLOAD_COMPLETED);
- dl->ctx->ecb (dl->ctx->ecbClosure, &event);
}
}
@@ -422,6 +410,7 @@
{
struct GNUNET_GE_Context *ectx;
GNUNET_FSUI_DownloadList *dpos;
+ GNUNET_FSUI_Event event;
int ret;
if (list == NULL)
@@ -488,10 +477,27 @@
ret = GNUNET_YES;
}
+
+ /* Trigger any recursive sub-downloads */
+ if (((list->state == GNUNET_FSUI_COMPLETED) ||
+ (list->state == GNUNET_FSUI_COMPLETED_JOINED)) &&
+ (list->is_directory == GNUNET_YES))
+ {
+ /* in case there is no sub-download, still
+ create the (possibly empty) directory! */
+ GNUNET_disk_directory_create (list->ctx->ectx, list->filename);
+ if ((list->is_recursive == GNUNET_YES) &&
+ (GNUNET_ECRS_uri_get_file_size (list->fi.uri) > 0))
+ {
+ download_recursive (list);
+ list->is_recursive = GNUNET_NO;
+ }
+ }
+
/* has this one "died naturally"? */
if ((list->state == GNUNET_FSUI_COMPLETED) ||
- (list->state == GNUNET_FSUI_ABORTED)
- || (list->state == GNUNET_FSUI_ERROR))
+ (list->state == GNUNET_FSUI_ABORTED) ||
+ (list->state == GNUNET_FSUI_ERROR))
{
#if DEBUG_DTM
GNUNET_GE_LOG (ectx,
@@ -502,24 +508,27 @@
GNUNET_ECRS_file_download_partial_stop (list->handle);
list->handle = NULL;
list->ctx->activeDownloadThreads--;
+ if (list->state == GNUNET_FSUI_COMPLETED)
+ {
+ /* generate event */
+ event.type = GNUNET_FSUI_download_completed;
+ event.data.DownloadCompleted.dc.pos = list;
+ event.data.DownloadCompleted.dc.cctx = list->cctx;
+ event.data.DownloadCompleted.dc.ppos =
+ list->parent == &list->ctx->activeDownloads ? NULL : list->parent;
+ event.data.DownloadCompleted.dc.pcctx = list->parent->cctx;
+ event.data.DownloadCompleted.dc.spos = list->search;
+ event.data.DownloadCompleted.dc.sctx =
+ list->search == NULL ? NULL : list->search->cctx;
+ event.data.DownloadCompleted.total = list->total;
+ event.data.DownloadCompleted.filename = list->filename;
+ event.data.DownloadCompleted.uri = list->fi.uri;
+ list->ctx->ecb (list->ctx->ecbClosure, &event);
+ }
list->state++; /* adds _JOINED */
ret = GNUNET_YES;
}
- /* Trigger any recursive sub-downloads */
- if (((list->state == GNUNET_FSUI_COMPLETED) ||
- (list->state == GNUNET_FSUI_COMPLETED_JOINED)) &&
- (list->is_directory == GNUNET_YES))
- {
- /* in case there is no sub-download, still
- create the (possibly empty) directory! */
- GNUNET_disk_directory_create (list->ctx->ectx, list->filename);
- if ((list->is_recursive == GNUNET_YES) &&
- (GNUNET_ECRS_uri_get_file_size (list->fi.uri) > 0))
- {
- download_recursive (list);
- list->is_recursive = GNUNET_NO;
- }
- }
+
dpos = list->child;
while (dpos != NULL)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6882 - GNUnet/src/applications/fs/fsui,
gnunet <=