mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-06 08:36:01 +00:00
Clean up FilePath. Extract one method out, and ensure closing of input stream after copy
This commit is contained in:
1 parent
71debc2b89
commit
4aab81f823
1 file changed
+12
-8
@@ -213,17 +213,18 @@ public final class FilePath implements Serializable {
|
||||
*/
|
||||
public FilePath(FilePath base, String rel) {
|
||||
this.channel = base.channel;
|
||||
if(isAbsolute(rel)) {
|
||||
// absolute
|
||||
this.remote = normalize(rel);
|
||||
} else
|
||||
this.remote = normalize(resolvePathIfRelative(base, rel));
|
||||
}
|
||||
|
||||
private String resolvePathIfRelative(FilePath base, String rel) {
|
||||
if(isAbsolute(rel)) return rel;
|
||||
if(base.isUnix()) {
|
||||
// shouldn't need this replace, but better safe than sorry
|
||||
this.remote = normalize(base.remote+'/'+rel.replace('\\','/'));
|
||||
return base.remote+'/'+rel.replace('\\','/');
|
||||
} else {
|
||||
// need this replace, see Slave.getWorkspaceFor and AbstractItem.getFullName, nested jobs on Windows
|
||||
// slaves will always have a rel containing at least one '/' character. JENKINS-13649
|
||||
this.remote = normalize(base.remote+'\\'+rel.replace('/','\\'));
|
||||
return base.remote+'\\'+rel.replace('/','\\');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -781,8 +782,11 @@ public final class FilePath implements Serializable {
|
||||
try {
|
||||
IOUtils.copy(i,o);
|
||||
} finally {
|
||||
o.close();
|
||||
i.close();
|
||||
try {
|
||||
o.close();
|
||||
} finally {
|
||||
i.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user