提交 c3f4ead8 编写于 作者: K kohsuke

file system provisioner related changes

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@12252 71c3de6d-444a-0410-be80-ed276b4c234a
上级 674845c1
......@@ -25,6 +25,7 @@ import org.apache.tools.tar.TarOutputStream;
import org.apache.tools.zip.ZipOutputStream;
import org.apache.tools.zip.ZipEntry;
import org.apache.commons.io.IOUtils;
import org.apache.commons.fileupload.FileItem;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
......@@ -326,6 +327,30 @@ public final class FilePath implements Serializable {
});
}
/**
* Place the data from {@link FileItem} into the file location specified by this {@link FilePath} object.
*/
public void copyFrom(FileItem file) throws IOException, InterruptedException {
if(channel==null) {
try {
file.write(new File(remote));
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw new IOException2(e);
}
} else {
InputStream i = file.getInputStream();
OutputStream o = write();
try {
IOUtils.copy(i,o);
} finally {
o.close();
i.close();
}
}
}
/**
* Code that gets executed on the machine where the {@link FilePath} is local.
* Used to act on {@link FilePath}.
......
......@@ -7,6 +7,7 @@ import hudson.model.Computer;
import hudson.model.Describable;
import hudson.model.Job;
import hudson.model.TaskListener;
import hudson.model.listeners.RunListener;
import hudson.util.DescriptorList;
import java.io.BufferedOutputStream;
......@@ -63,7 +64,8 @@ import java.io.OutputStream;
* the retention policy.
*
* Can't the 2nd step happen automatically, when someone else depends on
* the workspace snapshot of the upstream?
* the workspace snapshot of the upstream? Yes, by using {@link RunListener}.
* So this becomes like a special SCM type.
*
* To support promoted builds, we need an abstraction for permalinks.
* This is also needed for other UI.
......@@ -127,12 +129,18 @@ public abstract class FileSystemProvisioner implements ExtensionPoint, Describab
*/
public static final DescriptorList<FileSystemProvisioner> LIST = new DescriptorList<FileSystemProvisioner>();
/**
* Default implementation.
*/
public static final FileSystemProvisioner DEFAULT = new Default();
/**
* Default implementation that doesn't rely on any file system specific capability,
* and thus can be used anywhere that Hudson runs.
*/
public static final class Default extends FileSystemProvisioner {
private Default() {}
public void prepareWorkspace(AbstractBuild<?, ?> build, FilePath ws, TaskListener listener) throws IOException, InterruptedException {
ws.mkdirs();
}
......
......@@ -31,7 +31,7 @@ public abstract class FileSystemProvisionerDescriptor extends Descriptor<FileSys
* <p>
* This method is called to do this, after Hudson determines that the workspace should be deleted
* to reclaim disk space. The implementation of this method is expected to sniff the contents of
* the workspace, and if it looks like the one created by {@link FileSystemProvisioner#prepareWorkspace(AbstractBuild, TaskListener)},
* the workspace, and if it looks like the one created by {@link FileSystemProvisioner#prepareWorkspace(AbstractBuild, FilePath, TaskListener)},
* perform the necessary deletion operation, and return <tt>true</tt>.
*
* <p>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册