HADOOP-14065. AliyunOSS: oss directory filestatus should use meta time. Contributed by Fei Hui
This commit is contained in:
parent
37b4acf7ce
commit
a8a594b4c8
@ -218,7 +218,8 @@ public FileStatus getFileStatus(Path path) throws IOException {
|
||||
throw new FileNotFoundException(path + ": No such file or directory!");
|
||||
}
|
||||
} else if (objectRepresentsDirectory(key, meta.getContentLength())) {
|
||||
return new FileStatus(0, true, 1, 0, 0, qualifiedPath);
|
||||
return new FileStatus(0, true, 1, 0, meta.getLastModified().getTime(),
|
||||
qualifiedPath);
|
||||
} else {
|
||||
return new FileStatus(meta.getContentLength(), false, 1,
|
||||
getDefaultBlockSize(path), meta.getLastModified().getTime(),
|
||||
|
@ -24,6 +24,7 @@
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.fs.contract.ContractTestUtils;
|
||||
import org.apache.hadoop.io.IOUtils;
|
||||
import org.apache.hadoop.fs.FileStatus;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@ -142,4 +143,12 @@ public void testReadFile() throws Exception {
|
||||
assertTrue(instream.available() == 0);
|
||||
IOUtils.closeStream(instream);
|
||||
}
|
||||
@Test
|
||||
public void testDirectoryModifiedTime() throws Exception {
|
||||
Path emptyDirPath = setPath("/test/emptyDirectory");
|
||||
fs.mkdirs(emptyDirPath);
|
||||
FileStatus dirFileStatus = fs.getFileStatus(emptyDirPath);
|
||||
assertTrue("expected the empty dir is new",
|
||||
dirFileStatus.getModificationTime() > 0L);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user