HADOOP-14069. AliyunOSS: listStatus returns wrong file info. Contributed by Fei Hui

This commit is contained in:
Kai Zheng 2017-02-13 13:18:20 +08:00
parent 839b690ed5
commit 01be4503c3
2 changed files with 8 additions and 1 deletions

View File

@ -352,7 +352,7 @@ public FileStatus[] listStatus(Path path) throws IOException {
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("Adding: rd: " + keyPath); LOG.debug("Adding: rd: " + keyPath);
} }
result.add(new FileStatus(0, true, 1, 0, 0, keyPath)); result.add(getFileStatus(keyPath));
} }
} }

View File

@ -22,6 +22,7 @@
import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileAlreadyExistsException;
import org.apache.hadoop.fs.FileSystemContractBaseTest; import org.apache.hadoop.fs.FileSystemContractBaseTest;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.FileStatus;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
@ -206,6 +207,12 @@ public void testGetFileStatusFileAndDirectory() throws Exception {
assertTrue("Should be directory", assertTrue("Should be directory",
this.fs.getFileStatus(dirPath).isDirectory()); this.fs.getFileStatus(dirPath).isDirectory());
assertFalse("Should not be file", this.fs.getFileStatus(dirPath).isFile()); assertFalse("Should not be file", this.fs.getFileStatus(dirPath).isFile());
Path parentPath = this.path("/test/oss");
for (FileStatus fileStatus: fs.listStatus(parentPath)) {
assertTrue("file and directory should be new",
fileStatus.getModificationTime() > 0L);
}
} }
public void testMkdirsForExistingFile() throws Exception { public void testMkdirsForExistingFile() throws Exception {