On Tue, Feb 01, 2011 at 10:42:22AM +0300, Timur Sufiev wrote:
I think it would be convenient to specify arbitrary directory for
storing transfer_log (it is useful when several processes using lftp
I think it is better to specify a file name rather than a directory.
Use xfer:log-file setting name.
Here it is.
--
С уважением,
Суфиев Тимур
From b9869883f6720a7be90c30f2a1580adfcd6d6745 Mon Sep 17 00:00:00 2001
From: Timur Sufiev
Date: Mon, 31 Jan 2011 18:13:28 +0300
Subject: [PATCH] Add xfer:log-file parameter to write transfer log to arbitrary
file.
---
src/FileCopy.cc | 10 +-
src/ResMgr.cc |8
src/ResMgr.h|3 ++-
src/resource.cc |1 +
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/FileCopy.cc b/src/FileCopy.cc
index a462cca..ac386b7 100644
--- a/src/FileCopy.cc
+++ b/src/FileCopy.cc
@@ -629,7 +629,15 @@ void FileCopy::LogTransfer()
return;
if(!transfer_log)
{
- int
fd=open(dir_file(get_lftp_home(),"transfer_log"),O_WRONLY|O_APPEND|O_CREAT,0600);
+ const char *fname = ResMgr::Query("xfer:log-file", 0);
+ int fd;
+
+ if ( fname && strcmp(fname, "") ) {
+fd=open(fname,O_WRONLY|O_APPEND|O_CREAT,0600);
+ }
+ else
+
fd=open(dir_file(get_lftp_home(),"transfer_log"),O_WRONLY|O_APPEND|O_CREAT,0600);
+
if(fd==-1)
return;
transfer_log=new Log;
diff --git a/src/ResMgr.cc b/src/ResMgr.cc
index 18f98fb..5fbe32c 100644
--- a/src/ResMgr.cc
+++ b/src/ResMgr.cc
@@ -33,6 +33,7 @@
#include
#include
#include
+#include // to use dirname
CDECL_BEGIN
#include "regex.h"
CDECL_END
@@ -880,6 +881,13 @@ const char *ResMgr::DirReadable(xstring_c *value)
{
return FileAccessible(value,R_OK|X_OK,1);
}
+const char *ResMgr::DirOfFileWritable(xstring_c *value)
+{
+ if (!**value)
+return 0;
+ const char* dir = dirname(*value);
+ return FileAccessible(&xstring_c(dir),R_OK|X_OK|W_OK,1);
+}
#ifdef HAVE_ICONV
CDECL_BEGIN
diff --git a/src/ResMgr.h b/src/ResMgr.h
index 98ae105..acf708c 100644
--- a/src/ResMgr.h
+++ b/src/ResMgr.h
@@ -72,7 +72,7 @@ public:
private:
static Resource *chain;
static ResType *type_chain;
-
+
public:
static void AddType(ResType *t) { t->next=type_chain; type_chain=t; }
static const char *QueryNext(const char *name,const char **closure,Resource
**ptr);
@@ -112,6 +112,7 @@ public:
static const char *FileReadable(xstring_c *value);
static const char *FileExecutable(xstring_c *value);
static const char *DirReadable(xstring_c *value);
+ static const char *DirOfFileWritable(xstring_c *value);
static const char *CharsetValidate(xstring_c *value);
static const char *NoClosure(xstring_c *);
static bool str2bool(const char *value);
diff --git a/src/resource.cc b/src/resource.cc
index 213b7a7..70e3a5b 100644
--- a/src/resource.cc
+++ b/src/resource.cc
@@ -341,6 +341,7 @@ static ResType lftp_vars[] = {
{"xfer:verify-command", "", ResMgr::FileExecutable,0},
{"xfer:log", "yes",
ResMgr::BoolValidate,ResMgr::NoClosure},
{"xfer:auto-rename", "no",
ResMgr::BoolValidate,ResMgr::NoClosure},
+ {"xfer:log-file", "", ResMgr::DirOfFileWritable,0},
#if USE_SSL
{"ssl:ca-file", "",
ResMgr::FileReadable,ResMgr::NoClosure},
--
1.7.3.5