Skip to content

Commit b77dc84

Browse files
committed
mkdirs(..) tolerance + unit test.
1 parent b1d40f6 commit b77dc84

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/main/java/org/apache/hadoop/fs/glusterfs/GlusterFileSystem.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,14 @@ public boolean exists(Path path) throws IOException {
180180
return f.exists();
181181
}
182182

183-
public boolean mkdirs(Path path, FsPermission permission)
184-
throws IOException {
185-
boolean created = false;
186-
Path absolute = makeAbsolute(path);
187-
File f = new File(absolute.toUri().getPath());
188-
189-
if (f.exists()) {
190-
System.out.println("Directory " + f.getPath() + " already exist");
191-
return true;
192-
}
193-
194-
return f.mkdirs();
183+
public boolean mkdirs(Path f, FsPermission permission) throws IOException {
184+
185+
if(f==null) return true;
186+
187+
Path parent = f.getParent();
188+
Path absolute = makeAbsolute(f);
189+
File p2f = new File(absolute.toUri().getPath());
190+
return (f == null || mkdirs(parent)) && (p2f.mkdir() || p2f.isDirectory());
195191
}
196192

197193
@Deprecated

src/test/java/org/gluster/test/TestGluster.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public static void before() throws Exception{
138138

139139
@org.junit.Test
140140
public void testTolerantMkdirs() throws Exception{
141-
System.out.println("Testing tollerance of mkdirs(a/b/c/d) then mkdirs(a/b/c)");
141+
142142
Path longPath = new Path("a/b/c/d");
143143
assertFalse(gfs.exists(longPath));
144144
gfs.mkdirs(longPath);

0 commit comments

Comments
 (0)