提交 d621c000 编写于 作者: N Nicolas De loof

Merge pull request #462 from lacostej/lacostej-cleanup-FilePath

Clean up FilePath. Extract one method out and ensure closing of input stream after copy
......@@ -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();
}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册