[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r1907 - gnunet-gtk/src/plugins/fs
From: |
durner |
Subject: |
[GNUnet-SVN] r1907 - gnunet-gtk/src/plugins/fs |
Date: |
Thu, 25 Aug 2005 09:41:59 -0700 (PDT) |
Author: durner
Date: 2005-08-25 09:41:38 -0700 (Thu, 25 Aug 2005)
New Revision: 1907
Modified:
gnunet-gtk/src/plugins/fs/download.c
Log:
move completely downloaded files
Modified: gnunet-gtk/src/plugins/fs/download.c
===================================================================
--- gnunet-gtk/src/plugins/fs/download.c 2005-08-25 16:37:53 UTC (rev
1906)
+++ gnunet-gtk/src/plugins/fs/download.c 2005-08-25 16:41:38 UTC (rev
1907)
@@ -347,27 +347,53 @@
DOWNLOAD_LINKNAME, &ln,
-1);
if (ECRS_equalsUri(u, uri)) {
+ char *dstPath, *newFn, *dstFile;
+
ren = ECRS_suggestFilename(ln);
- if (ren != NULL) {
- gtk_tree_store_set(summary,
- &iter,
- DOWNLOAD_LINKNAME, ren,
- -1);
- if (0 == strcmp(fn, ln)) {
- /* keep the actual data under the URI name
- and create a symlink */
- if (0 != RENAME(ren, fn))
- LOG(LOG_ERROR,
- _("Renaming of file `%s' to `%s' failed: %s\n"),
- ren,
- fn,
- STRERROR(errno));
- else
- if (0 != SYMLINK(fn, ren))
- LOG_FILE_STRERROR(LOG_ERROR, "symlink", ren);
+ newFn = strrchr(ren ? ren : ln, DIR_SEPARATOR) + 1;
+ dstPath = getConfigurationString("FS", "INCOMINGDIR");
+ if (!dstPath) {
+ LOG(LOG_ERROR, _("You must specify a directory in the configuration"
+ " in section `%s' under `%s'."), "FS", "INCOMINGDIR");
+
+ return;
+ }
+ mkdirp(dstPath);
+
+ dstFile = MALLOC(strlen(dstPath) + strlen(newFn) + 2);
+ strcpy(dstFile, dstPath);
+ strcat(dstFile, DIR_SEPARATOR_STR);
+ strcat(dstFile, newFn);
+
+ if (RENAME(fn, dstFile) == -1) {
+ /* renaming failed, try to copy */
+ if (!copyFile(fn, dstFile)) {
+ LOG(LOG_ERROR, _("Could not move or copy downloaded file %s to %s:
%s."),
+ fn, dstFile, STRERROR(errno));
+ FREE(dstFile);
+ FREE(ren);
+
+ return;
}
- FREE(ren);
+
+ if (REMOVE(fn) == -1)
+ LOG(LOG_ERROR, _("Could not remove temporary file %s: %s\n"), fn,
STRERROR(errno));
}
+
+ if (ren)
+ REMOVE(ren);
+ else
+ REMOVE(ln);
+ SYMLINK(dstFile, fn);
+
+ gtk_tree_store_set(summary,
+ &iter,
+ DOWNLOAD_LINKNAME, dstFile,
+ -1);
+ FREENONNULL(ren);
+ FREE(dstFile);
+ FREE(dstPath);
+
break;
}
} while (gtk_tree_model_iter_next(GTK_TREE_MODEL(summary),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r1907 - gnunet-gtk/src/plugins/fs,
durner <=