diff --git a/src/MirrorJob.cc b/src/MirrorJob.cc index 595c37b..7eaea27 100644 --- a/src/MirrorJob.cc +++ b/src/MirrorJob.cc @@ -914,24 +914,21 @@ int MirrorJob::Do() } continue; } + bool use_rmdir = (file->defined&file->TYPE && file->filetype==file->DIRECTORY) + && (flags&NO_RECURSION); if(script) { - ArgV args("rm"); - if(file->defined&file->TYPE && file->filetype==file->DIRECTORY) - { - if(flags&NO_RECURSION) - args.setarg(0,"rmdir"); - else + ArgV args(use_rmdir?"rmdir":"rm"); + if((file->defined&file->TYPE && file->filetype==file->DIRECTORY) && !use_rmdir) args.Append("-r"); - } args.Append(target_session->GetFileURL(file->name)); xstring_ca cmd(args.CombineQuoted()); fprintf(script,"%s\n",cmd.get()); } if(!script_only) { - ArgV *args=new ArgV("rm"); - args->Append(file->name); + ArgV *args=new ArgV(use_rmdir?"rmdir":"rm"); + args->Append(dir_file(".",file->name)); args->seek(1); rmJob *j=new rmJob(target_session->Clone(),args); j->cmdline.set_allocated(args->Combine()); @@ -940,10 +937,7 @@ int MirrorJob::Do() if(file->defined&file->TYPE && file->filetype==file->DIRECTORY) { if(flags&NO_RECURSION) - { - args->setarg(0,"rmdir"); j->Rmdir(); - } else j->Recurse(); } @@ -1014,7 +1008,7 @@ int MirrorJob::Do() if(!script_only) { ArgV *a=new ArgV("chmod"); - a->Append(file->name); + a->Append(dir_file(".",file->name)); a->seek(1); ChmodJob *cj=new ChmodJob(target_session->Clone(), file->mode&~mode_mask,a);