Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ private static OzoneKey toOzoneKey(OzoneFileStatusLight status) {
keyInfo.getModificationTime(),
keyInfo.getReplicationConfig(),
metadata,
keyInfo.isFile(),
status.isFile(),
keyInfo.getOwnerName(),
Collections.emptyMap());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
import org.apache.hadoop.ozone.client.ObjectStore;
import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneKey;
import org.apache.hadoop.ozone.client.OzoneKeyDetails;
import org.apache.hadoop.ozone.client.OzoneVolume;
import org.apache.hadoop.ozone.client.VolumeArgs;
Expand Down Expand Up @@ -2588,4 +2589,27 @@ private void deleteFiles(Path base, List<String> fileNames) throws IOException {
}
}

@Test
void testIsFileFalseForDir() throws IOException {
Copy link
Contributor

@chungen0126 chungen0126 May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should add the test here, as it's not an operation of FileSystem. Could you please move the test to TestListKeysWithFSO?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Path dirPath = new Path(getBucketPath(), "dir1");
Path keyPath = new Path(dirPath, "key1");
OFSPath ofsPath = new OFSPath(dirPath, conf);

getFs().mkdirs(dirPath);
try (FSDataOutputStream out1 = getFs().create(keyPath)) {
out1.write(2);
}

OzoneBucket bucket = adapter.getBucket(ofsPath, false);

Iterator<? extends OzoneKey> keyIterator = bucket.listKeys("");

assertTrue(keyIterator.hasNext(), "Expected dir1, key1 in the bucket");
OzoneKey ozoneKey = keyIterator.next();
assertEquals("dir1/", ozoneKey.getName());
assertFalse(ozoneKey.isFile(), "Expected isFile to be false for directory key");
ozoneKey = keyIterator.next();
assertEquals("dir1/key1", ozoneKey.getName());
assertTrue(ozoneKey.isFile(), "Expected isFile to be true for key");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,5 +225,4 @@ void testLeaseRecoverable() throws Exception {
TestLeaseRecovery.closeIgnoringKeyNotFound(stream);
}
}

}