Skip to content

Commit ac6f0f1

Browse files
committed
Fix mock fs stat not woking on *nix with converted local path
Signed-off-by: Wei Zhang <[email protected]>
1 parent 9ed9e3f commit ac6f0f1

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Utils/hdinsight-node-common/src/com/microsoft/azure/hdinsight/spark/mock/MockRawLocalFileSystem.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public Path getLinkTarget(Path f) throws IOException {
9090
// Get File or Link status from supported native file system
9191
private FileStatus getNativeFileLinkStatus(final Path f,
9292
boolean dereference) throws IOException {
93-
Stat stat = new Stat(f, getDefaultBlockSize(f), dereference, this);
93+
MockStat stat = new MockStat(f, getDefaultBlockSize(f), dereference, this);
9494
FileStatus status = stat.getFileStatus();
9595
status.setPath(f);
9696

@@ -320,4 +320,26 @@ public void write(DataOutput out) throws IOException {
320320
super.write(out);
321321
}
322322
}
323+
324+
class MockStat extends Stat {
325+
private Path originPath;
326+
327+
public MockStat(Path path, long blockSize, boolean deref, FileSystem fs) throws IOException {
328+
super(path, blockSize, deref, fs);
329+
330+
this.originPath = path;
331+
}
332+
333+
@Override
334+
protected String[] getExecString() {
335+
String[] execArgs = super.getExecString();
336+
337+
if (execArgs.length > 1) {
338+
// Override the wasb or mockfs path with the converted local file path
339+
execArgs[execArgs.length - 1] = pathToFile(this.originPath).getPath();
340+
}
341+
342+
return execArgs;
343+
}
344+
}
323345
}

0 commit comments

Comments
 (0)