Bug 12765

Summary: "rmdir" and "deltree" patches for ftp task enhancement
Product: Ant Reporter: Gabriele Garuglieri <gabriele.garuglieri>
Component: Optional TasksAssignee: Ant Notifications List <notifications>
Status: NEW ---    
Severity: enhancement Keywords: PatchAvailable
Priority: P3    
Version: 1.5   
Target Milestone: ---   
Hardware: Other   
OS: other   
Attachments: "rmdir" action patch
"rmdir" action patch
"deltree" action patch
"deltree" action patch

Description Gabriele Garuglieri 2002-09-18 11:43:58 UTC
I have written for my own use a couple of enhancements to <ftp> i would like to
see integrated into ant distribution.
I have added "rmdir" and "deltree" actions.
"rmdir" makes, well, what it says, removes from the remote server all the
directories matched by the filesets.
"deltree" is a pseudo action that is internally exploded in a "delete" and 
"rmdir" action using the same filesets.
More explanations are given in the updated documentation.
Patches are included.
I couldn't use cvs diff, because i'm behind a firewall and cannot access your
cvs server. I used GNU diff -u to produce patches files.
Comment 1 Gabriele Garuglieri 2002-09-18 12:26:46 UTC
Created attachment 3112 [details]
"rmdir" action patch
Comment 2 Gabriele Garuglieri 2002-09-18 12:27:48 UTC
Created attachment 3113 [details]
"rmdir" action patch
Comment 3 Gabriele Garuglieri 2002-09-18 12:28:23 UTC
Created attachment 3114 [details]
"deltree" action patch
Comment 4 Gabriele Garuglieri 2002-09-18 12:28:44 UTC
Created attachment 3115 [details]
"deltree" action patch
Comment 5 Gabriele Garuglieri 2002-09-18 12:43:34 UTC
Patch for "rmdir" action:
attachment 3112 [details] : patch for 
jakarta-ant-1.5\src\main\org\apache\tools\ant\taskdefs\optional\net\FTP.java
attachment 3113 [details] : patch for jakarta-ant-1.5\docs\manual\OptionalTasks\ftp.html

Patch for "deltree" action (need previous patch as prerequisite):
attachment 3114 [details] : patch for
jakarta-ant-1.5\src\main\org\apache\tools\ant\taskdefs\optional\net\FTP.java
attachment 3115 [details] : patch for jakarta-ant-1.5\docs\manual\OptionalTasks\ftp.html

Pls let me know if you plan to include this into ant distribution since i'd like
to implement some production procedures based on this behaviour.
Comment 6 Stefan Bodewig 2002-09-23 16:01:09 UTC
I've committed the first part but am reluctant on the second as it changes the
published API of this task (and there already is at least one user written
subtask of this I am aware of).

can you rework the patch to preserve transferFiles(FTPClient, FileSet)?
Comment 7 Gabriele Garuglieri 2002-09-24 06:12:23 UTC
Well, Stefan, you are rigth. I don't like it myself the way i implemented it.
It was a quick and dirty work.
I thought of a different way, and i'll try to implement it when i get some new
spare time, but i'd like an advice.
Do you think is better to keep the "deltree" action that doesn't correspond to
any real FTP command or adding an attribute, like deltree="true/false", to
"delete" and "rmdir" to say: when true don't limit yourself to files or dirs but
delete everything selected by the filesets? I would prefer the second way, but
i'll stick with your decision.

One more thing, i have implemented a couple more attributes:
"purgeRemoteAfterSend" that together with "send" action, i use to maintain in
sync local an remote directories, in the sense that everything that was not
selected for send is deleted from remote server, so i end with specular local
and remote trees.
"dryrun" that just simulate execution without doing anything. When used with
verbose it produce a complete report of what it would have done. I find it very
useful expecially when deleting or removing to test filesets patterns.
They work for me but the code is not yet clean enough for a submission.
Do you think you may be intererested in this?

Thanks,  Gabriele.
Comment 8 Stefan Bodewig 2002-09-25 14:17:55 UTC
Well, if we follow the attribute route you line out, we could also simply drop
rmdir again and tell delete to work on files, directories or both of them.

For your second option I would never use ftp for this, but simply rely on rsync,
which even works over ssh.

I haven't tried, but maybe using a <present> selector with the delete action works
here (so you'd end up writing two <ftp>s in your build file).