On Wed, May 23, 2001 at 11:41:16AM -0500, Mike wrote:
> I was wondering if there's a reason you can't continue reversed mirrors (mirror -c
>-R <somedir>). Spent some time on the mailing lists, but not alot, so I don't know if
>anyone else had posted something like this before.
>
> I was kinda pokin around the src (MirrorJob.cc), saw some stuff, like cont_this =
>true and such, but nothing in the functions that handle reverse mirrors. Think I'm
>lookin at the right place anyway.
Thanks for report. Here is the patch I made (attached).
> lftp is awesome, real easy to read src (for the parts I've looked at anyway), I was
>tyring to figure out custom completers, so after I got lost in the bash src, i looked
>to lftp, and ahh, it was a miracle :)
Thanks :) But there are some people who don't like my coding style.
--
Alexander. | http://www.yars.free.net/~lav/
Index: MirrorJob.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/MirrorJob.cc,v
retrieving revision 1.62
diff -u -r1.62 MirrorJob.cc
--- MirrorJob.cc 2001/04/17 09:52:05 1.62
+++ MirrorJob.cc 2001/05/24 10:06:02
@@ -158,32 +158,46 @@
case(FileInfo::NORMAL):
{
try_get:
- bool cont_this=false;
+ cont_this=false;
if(how!=0)
goto skip;
if(flags&REVERSE)
{
- if(remote_set->FindByName(file->name)!=0)
+ FileInfo *old=remote_set->FindByName(file->name);
+ if(old)
{
- Report(_("Removing old remote file `%s'"),
- dir_file(remote_relative_dir,file->name));
- args=new ArgV("rm");
- args->Append(file->name);
- if(script)
+ if((flags&CONTINUE)
+ && (old->defined&file->TYPE) && old->filetype==old->NORMAL
+ && (file->defined&(file->DATE|file->DATE_UNPREC))
+ && (old->defined&(old->DATE|old->DATE_UNPREC))
+ && file->date + prec.Seconds() < old->date
+ && (file->defined&file->SIZE) && (old->defined&old->SIZE)
+ && file->size >= old->size)
{
- char *cmd=args->CombineQuoted();
- fprintf(script,"%s",cmd);
- xfree(cmd);
- if(script_only)
+ cont_this=true;
+ }
+ else
+ {
+ Report(_("Removing old remote file `%s'"),
+ dir_file(remote_relative_dir,file->name));
+ args=new ArgV("rm");
+ args->Append(file->name);
+ if(script)
{
- delete args;
- goto skip;
+ char *cmd=args->CombineQuoted();
+ fprintf(script,"%s",cmd);
+ xfree(cmd);
+ if(script_only)
+ {
+ delete args;
+ goto skip;
+ }
}
+ Job *j=new rmJob(Clone(),args);
+ j->SetParentFg(this);
+ j->cmdline=args->Combine();
+ AddWaiting(j);
}
- Job *j=new rmJob(Clone(),args);
- j->SetParentFg(this);
- j->cmdline=args->Combine();
- AddWaiting(j);
mod_files++;
}
else
@@ -638,6 +652,8 @@
if(script)
{
args=new ArgV("put1");
+ if(cont_this)
+ args->Append("-c");
args->Append(local_name);
args->Append("-o");
args->Append(file->name);
@@ -655,7 +671,7 @@
FileCopyPeer *src_peer=
FileCopyPeerFDStream::NewGet(local_name);
- FileCopy *c=FileCopy::New(src_peer,dst_peer,false);
+ FileCopy *c=FileCopy::New(src_peer,dst_peer,cont_this);
if(remove_source_files)
c->RemoveSourceLater();
CopyJob *cp=
@@ -897,6 +913,7 @@
remote_set=local_set=0;
new_files_set=old_files_set=0;
file=0;
+ cont_this=false;
list_info=0;
local_session=0;
Index: MirrorJob.h
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/MirrorJob.h,v
retrieving revision 1.16
diff -u -r1.16 MirrorJob.h
--- MirrorJob.h 2000/09/07 18:38:36 1.16
+++ MirrorJob.h 2001/05/24 10:05:24
@@ -74,6 +74,8 @@
FileInfo *file;
void HandleFile(int);
+ bool cont_this; // try to continue transfer of current file.
+
ListInfo *list_info;
FileAccess *local_session;