ASF Bugzilla – Attachment 3114 Details for
Bug 12765
"rmdir" and "deltree" patches for ftp task enhancement
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
"deltree" action patch
FTP.java.deltree.patch (text/plain), 6.62 KB, created by
Gabriele Garuglieri
on 2002-09-18 12:28:23 UTC
(
hide
)
Description:
"deltree" action patch
Filename:
MIME Type:
Creator:
Gabriele Garuglieri
Created:
2002-09-18 12:28:23 UTC
Size:
6.62 KB
patch
obsolete
>--- FTP.java.orig Tue Sep 17 14:40:21 2002 >+++ FTP.java Wed Sep 18 12:45:22 2002 >@@ -89,6 +89,9 @@ > * <li> <strong>chmod</strong> - change unix file permissions.</li> > * <li> <strong>rmdir</strong> - remove directories, if empty, from a > * remote server.</li> >+ * <li> <strong>deltree</strong> - pseudo action that removes an entire file >+ * tree, and is equivalent to executing del action then rmdir action with >+ * the same fileset.</li> > * </ul> > * <strong>Note:</strong> Some FTP servers - notably the Solaris server - seem > * to hold data ports open after a "retr" operation, allowing them to timeout >@@ -113,6 +116,7 @@ > protected static final int MK_DIR = 4; > protected static final int CHMOD = 5; > protected static final int RM_DIR = 6; >+ protected static final int DEL_TREE = 20; > > private String remotedir; > private String server; >@@ -166,6 +170,10 @@ > "directories" > }; > >+ protected static final int[] PSEUDO_DEL_TREE_ACTIONS_LIST = { >+ DEL_FILES, >+ RM_DIR >+ }; > > protected class FTPDirectoryScanner extends DirectoryScanner { > protected FTPClient ftp = null; >@@ -478,20 +486,13 @@ > > > /** >- * For each file in the fileset, do the appropriate action: send, get, >- * delete, or list. >+ * For each file in the scanned files, do the appropriate action: send, get, >+ * delete, rmdir or list. > */ >- protected int transferFiles(FTPClient ftp, FileSet fs) >+ protected int transferFiles(FTPClient ftp, FileScanner ds) > throws IOException, BuildException { >- FileScanner ds; > >- if (action == SEND_FILES) { >- ds = fs.getDirectoryScanner(project); >- } else { >- ds = new FTPDirectoryScanner(ftp); >- fs.setupDirectoryScanner(ds, project); >- ds.scan(); >- } >+ log(ACTION_STRS[action] + " " + ACTION_TARGET_STRS[action]); > > String[] dsfiles = null; > if (action == RM_DIR) { >@@ -575,6 +576,14 @@ > } > } > >+ log(transferred + " " + ACTION_TARGET_STRS[action] + " " + >+ COMPLETED_ACTION_STRS[action]); >+ if (skipped != 0) { >+ log(skipped + " " + ACTION_TARGET_STRS[action] + >+ " were not successfully " >+ + COMPLETED_ACTION_STRS[action]); >+ } >+ > return dsfiles.length; > } > >@@ -587,6 +596,16 @@ > throws IOException, BuildException { > transferred = 0; > skipped = 0; >+ FileScanner ds; >+ int[] totTransferred; >+ int[] totSkipped; >+ >+ totTransferred = new int[ACTION_TARGET_STRS.length]; >+ totSkipped = new int[totTransferred.length]; >+ for (int j = 0; j < totTransferred.length; j++) { >+ totTransferred[j] = 0; >+ totSkipped[j] = 0; >+ } > > if (filesets.size() == 0) { > throw new BuildException("at least one fileset must be specified."); >@@ -596,17 +615,60 @@ > FileSet fs = (FileSet) filesets.elementAt(i); > > if (fs != null) { >- transferFiles(ftp, fs); >+ >+ if (action == SEND_FILES) { >+ ds = fs.getDirectoryScanner(project); >+ } else { >+ ds = new FTPDirectoryScanner(ftp); >+ fs.setupDirectoryScanner(ds, project); >+ ds.scan(); >+ } >+ >+ if (action == DEL_TREE) { >+ /* >+ * DEL_TREE is a pseudo action that is exploded >+ * into DEL_FILES and RM_DIR real actions. >+ * DEL_FILES will use getIncludedFiles() and >+ * and RM_DIR will use getIncludedDirectories() >+ * from the same FileScanner without rescanning >+ * remotedir. >+ */ >+ for (int a = 0; >+ a < PSEUDO_DEL_TREE_ACTIONS_LIST.length; >+ a++) { >+ action = PSEUDO_DEL_TREE_ACTIONS_LIST[a]; >+ >+ transferFiles(ftp, ds); >+ >+ totTransferred[action] += transferred; >+ transferred = 0; >+ totSkipped[action] += skipped; >+ skipped = 0; >+ >+ } >+ action = DEL_TREE; >+ } else { >+ transferFiles(ftp, ds); >+ } > } > } > } >- >- log(transferred + " " + ACTION_TARGET_STRS[action] + " " + >- COMPLETED_ACTION_STRS[action]); >- if (skipped != 0) { >- log(skipped + " " + ACTION_TARGET_STRS[action] + >- " were not successfully " >- + COMPLETED_ACTION_STRS[action]); >+ if (action == DEL_TREE) { >+ for (int a = 0; >+ a < PSEUDO_DEL_TREE_ACTIONS_LIST.length; >+ a++) { >+ action = PSEUDO_DEL_TREE_ACTIONS_LIST[a]; >+ log("Total " + totTransferred[action] + >+ " " + ACTION_TARGET_STRS[action] + " " + >+ COMPLETED_ACTION_STRS[action]); >+ if (totSkipped[action] != 0) { >+ log("Total " + totSkipped[action] + >+ " " + ACTION_TARGET_STRS[action] + >+ " were not successfully " >+ + COMPLETED_ACTION_STRS[action]); >+ } >+ } >+ action = DEL_TREE; > } > } > >@@ -1024,7 +1086,6 @@ > ftp.getReplyString()); > } > } >- log(ACTION_STRS[action] + " " + ACTION_TARGET_STRS[action]); > transferFiles(ftp); > } > >@@ -1047,13 +1108,13 @@ > /** > * an action to perform, one of > * "send", "put", "recv", "get", "del", "delete", "list", "mkdir", "chmod", >- * "rmdir" >+ * "rmdir", "deltree" > */ > public static class Action extends EnumeratedAttribute { > > private static final String[] validActions = { > "send", "put", "recv", "get", "del", "delete", "list", "mkdir", >- "chmod", "rmdir" >+ "chmod", "rmdir", "deltree" > }; > > >@@ -1082,6 +1143,8 @@ > return MK_DIR; > } else if (actionL.equals("rmdir")) { > return RM_DIR; >+ } else if (actionL.equals("deltree")) { >+ return DEL_TREE; > } > return SEND_FILES; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 12765
:
3112
|
3113
| 3114 |
3115