- If a write results in a file creation, do the create check, to align with the POSIX semantics.
- Don't make pointless mkdirs check if the directory already exists
- read vs readSymlink difference is dangerous because read() can be called for symlinks in other context as well.
This commit is contained in:
Kohsuke Kawaguchi committed 2014-09-18 18:52:05 -07:00
1 parent e4a1ac2ba1
commit 7bd7e4f0b2
1 file changed
+8 -3
+8 -3
View File
@@ -2563,13 +2563,13 @@ public final class FilePath implements Serializable {
@Override
public void visitSymlink(File link, String target, String relativePath) throws IOException {
filter.readSymlink(link);
filter.read(link);
v.visitSymlink(link, target, relativePath);
}
@Override
public boolean understandsSymlink() {
return true;
return v.understandsSymlink();
}
};
}
@@ -2602,7 +2602,10 @@ public final class FilePath implements Serializable {
* Pass through 'f' after ensuring that we can write to that file.
*/
private static File writing(File f) {
FilePathFilter.currentNonnull().write(f);
FilePathFilter filter = FilePathFilter.currentNonnull();
if (!f.exists())
filter.create(f);
filter.write(f);
return f;
}
@@ -2616,6 +2619,8 @@ public final class FilePath implements Serializable {
private static boolean mkdirs(File dir) {
if (dir.exists()) return false;
FilePathFilter.currentNonnull().mkdirs(dir);
return dir.mkdirs();
}