The branch, v3-2-test has been updated via 3482cd9b0e81bbc801f1cec33fca82fc45a3ddef (commit) via e2345ce90c3f1548f63d720c5943c8d61fdc899a (commit) via 3cfa35fca64b059b307668ca0113503679e0b1fa (commit) from 0f14357c86aee9a76ffbb45ea6419f4cc4106d62 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test - Log ----------------------------------------------------------------- commit 3482cd9b0e81bbc801f1cec33fca82fc45a3ddef Merge: e2345ce90c3f1548f63d720c5943c8d61fdc899a 0f14357c86aee9a76ffbb45ea6419f4cc4106d62 Author: Jelmer Vernooij <[EMAIL PROTECTED]> Date: Wed Mar 5 19:42:15 2008 +0100 Merge branch 'v3-2-test' of ssh://git.samba.org/data/git/samba into v3-2-test commit e2345ce90c3f1548f63d720c5943c8d61fdc899a Author: Jelmer Vernooij <[EMAIL PROTECTED]> Date: Wed Mar 5 17:30:18 2008 +0100 Fix formatting. commit 3cfa35fca64b059b307668ca0113503679e0b1fa Author: Charles <[EMAIL PROTECTED]> Date: Wed Mar 5 15:20:29 2008 +0100 Add --update option to smbget. ----------------------------------------------------------------------- Summary of changes: source/utils/smbget.c | 29 ++++++++++++++++++++++++++--- 1 files changed, 26 insertions(+), 3 deletions(-) Changeset truncated at 500 lines: diff --git a/source/utils/smbget.c b/source/utils/smbget.c index 63b7f48..e5185d0 100644 --- a/source/utils/smbget.c +++ b/source/utils/smbget.c @@ -29,7 +29,7 @@ int columns = 0; -static int _resume, _recursive, debuglevel; +static int _resume, _recursive, debuglevel, update; static char *outputfile; @@ -303,8 +303,26 @@ static int smb_download_file(const char *base, const char *name, int recursive, if(newpath[0] == '/')newpath++; - /* Open local file and, if necessary, resume */ - if(!send_stdout) { + /* Open local file according to the mode */ + if(update) { + /* if it is up-to-date, skip */ + if(stat(newpath, &localstat) == 0 && + localstat.st_mtime >= remotestat.st_mtime) { + if(verbose) + printf("%s is up-to-date, skipping\n", newpath); + smbc_close(remotehandle); + return 0; + } + /* else open it for writing and truncate if it exists */ + localhandle = open(newpath, O_CREAT | O_NONBLOCK | O_RDWR | O_TRUNC, 0775); + if(localhandle < 0) { + fprintf(stderr, "Can't open %s : %s\n", newpath, + strerror(errno)); + smbc_close(remotehandle); + return 1; + } + /* no offset */ + } else if(!send_stdout) { localhandle = open(newpath, O_CREAT | O_NONBLOCK | O_RDWR | (!resume?O_EXCL:0), 0755); if(localhandle < 0) { fprintf(stderr, "Can't open %s: %s\n", newpath, strerror(errno)); @@ -527,6 +545,7 @@ int main(int argc, const char **argv) {"guest", 'a', POPT_ARG_NONE, NULL, 'a', "Work as user guest" }, {"encrypt", 'e', POPT_ARG_NONE, NULL, 'e', "Encrypt SMB transport (UNIX extended servers only)" }, {"resume", 'r', POPT_ARG_NONE, &_resume, 0, "Automatically resume aborted files" }, + {"update", 'U', POPT_ARG_NONE, &update, 0, "Download only when remote file is newer than local file or local file is missing"}, {"recursive", 'R', POPT_ARG_NONE, &_recursive, 0, "Recursively download files" }, {"username", 'u', POPT_ARG_STRING, &username, 'u', "Username to use" }, {"password", 'p', POPT_ARG_STRING, &password, 'p', "Password to use" }, @@ -576,6 +595,10 @@ int main(int argc, const char **argv) } } + if((send_stdout || _resume || outputfile) && update) { + fprintf(stderr, "The -o, -R or -O and -U options can not be used together.\n"); + return 1; + } if((send_stdout || outputfile) && _recursive) { fprintf(stderr, "The -o or -O and -R options can not be used together.\n"); return 1; -- Samba Shared Repository