aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--slack-desc2
-rw-r--r--src/curl.c28
-rw-r--r--src/curl.h7
-rw-r--r--src/main.h1
5 files changed, 25 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index e9208e3..57038c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
-0.9.11a Dec 5, 2005
+0.9.11a Dec 9, 2005
+ * now preserves access and modification time of downloaded package
* added Indonesian translation by Kemas Antonius
* updated Portuguese_Portugal translation from Miguel
* updated Polish translation from Piotr
diff --git a/slack-desc b/slack-desc
index e9ddab9..c36ffff 100644
--- a/slack-desc
+++ b/slack-desc
@@ -9,7 +9,7 @@
slapt-get: slapt-get (APT like system for Slackware)
slapt-get: slapt-get is an APT like system for Slackware package management.
slapt-get:
-slapt-get: * See /usr/doc/slapt-get-0.9.11/ for complete documentation.
+slapt-get: * See /usr/doc/slapt-get-0.9.11a/ for complete documentation.
slapt-get: * You will also want to customize /etc/slapt-get/slapt-getrc,
slapt-get: using a local mirror. www.slackware.com may be very busy.
slapt-get: * Support:
diff --git a/src/curl.c b/src/curl.c
index 42f2e61..39559c2 100644
--- a/src/curl.c
+++ b/src/curl.c
@@ -25,7 +25,7 @@ struct head_data_t {
size_t size;
};
-int slapt_download_data(FILE *fh,const char *url,size_t bytes,
+static int slapt_download_data(FILE *fh,const char *url,size_t bytes,long *filetime,
const slapt_rc_config *global_config)
{
CURL *ch = NULL;
@@ -78,23 +78,28 @@ int slapt_download_data(FILE *fh,const char *url,size_t bytes,
/*
* this is for proxy servers that can't resume
*/
- if (response == CURLE_HTTP_RANGE_ERROR) {
+ if ( response == CURLE_HTTP_RANGE_ERROR ) {
return_code = CURLE_HTTP_RANGE_ERROR;
- } else if (response == CURLE_FTP_BAD_DOWNLOAD_RESUME) {
+ } else if ( response == CURLE_FTP_BAD_DOWNLOAD_RESUME ) {
return_code = CURLE_FTP_BAD_DOWNLOAD_RESUME;
- } else if (response == CURLE_PARTIAL_FILE) {
+ } else if ( response == CURLE_PARTIAL_FILE ) {
return_code = CURLE_PARTIAL_FILE;
/*
* this is a simple hack for all ftp sources that won't have a patches dir
* we don't want an ugly error to confuse the user
*/
- } else if (strstr(url,SLAPT_PATCHES_LIST) != NULL) {
+ } else if ( strstr(url,SLAPT_PATCHES_LIST) != NULL ) {
return_code = 0;
} else {
fprintf(stderr,gettext("Failed to download: %s\n"),curl_err_buff);
return_code = -1;
}
}
+
+ if ( filetime != NULL ) {
+ curl_easy_getinfo(ch, CURLINFO_FILETIME, filetime);
+ }
+
/*
* need to use curl_easy_cleanup() so that we don't
* have tons of open connections, getting rejected
@@ -187,7 +192,7 @@ int slapt_get_mirror_data_from_source(FILE *fh,
url[ strlen(base_url) ] = '\0';
strncat(url,filename,strlen(filename) );
- return_code = slapt_download_data(fh,url,0,global_config);
+ return_code = slapt_download_data(fh,url,0,NULL,global_config);
free(url);
/* make sure we are back at the front of the file */
@@ -205,6 +210,7 @@ int slapt_download_pkg(const slapt_rc_config *global_config,
size_t f_size = 0;
int pkg_verify_return = -1;
int dl_return = -1, dl_total_size = 0;
+ long filetime = 0;
if (slapt_verify_downloaded_pkg(global_config,pkg) == 0)
return 0;
@@ -260,7 +266,7 @@ int slapt_download_pkg(const slapt_rc_config *global_config,
}
/* download the file to our file handle */
- dl_return = slapt_download_data(fh,url,f_size,global_config);
+ dl_return = slapt_download_data(fh,url,f_size,&filetime,global_config);
if (dl_return == 0) {
if (global_config->dl_stats == SLAPT_FALSE &&
@@ -321,6 +327,14 @@ int slapt_download_pkg(const slapt_rc_config *global_config,
fclose(fh);
free(url);
+ /* preserve the file access and modification time */
+ if ( filetime > 0 ) {
+ struct utimbuf times;
+ times.actime = (time_t)filetime;
+ times.modtime = (time_t)filetime;
+ utime(file_name, &times); /* set the time we got */
+ }
+
/* check to make sure we have the complete file */
pkg_verify_return = slapt_verify_downloaded_pkg(global_config,pkg);
if (pkg_verify_return == 0) {
diff --git a/src/curl.h b/src/curl.h
index 2c05650..d4c7522 100644
--- a/src/curl.h
+++ b/src/curl.h
@@ -1,12 +1,5 @@
/*
- this is the main download routine, returns 0 on success. On error returns
- -1 or CURLE_HTTP_RANGE_ERROR
-*/
-int slapt_download_data(FILE *fh,const char *url,size_t bytes,
- const slapt_rc_config *global_config);
-
-/*
retrieves the head data for the url, returns (char *) or NULL on error
*/
char *slapt_head_request(const char *url);
diff --git a/src/main.h b/src/main.h
index 600cc8f..4f90aaa 100644
--- a/src/main.h
+++ b/src/main.h
@@ -39,6 +39,7 @@
#include <sys/statvfs.h>
#include <sys/mman.h>
#include <zlib.h>
+#include <utime.h>
#include "common.h"
#include "configuration.h"