Skip to content

Commit

Permalink
Core: Use FileIO for metadata file exist check
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzelAliz committed Dec 25, 2024
1 parent af8e3f5 commit f7995d5
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,14 @@ public long newSnapshotId() {
Path getMetadataFile(int metadataVersion) throws IOException {
for (TableMetadataParser.Codec codec : TABLE_METADATA_PARSER_CODEC_VALUES) {
Path metadataFile = metadataFilePath(metadataVersion, codec);
FileSystem fs = getFileSystem(metadataFile, conf);
if (fs.exists(metadataFile)) {
if (io().newInputFile(metadataFile.toString()).exists()) {
return metadataFile;
}

if (codec.equals(TableMetadataParser.Codec.GZIP)) {
// we have to be backward-compatible with .metadata.json.gz files
metadataFile = oldMetadataFilePath(metadataVersion, codec);
fs = getFileSystem(metadataFile, conf);
if (fs.exists(metadataFile)) {
if (io().newInputFile(metadataFile.toString()).exists()) {
return metadataFile;
}
}
Expand Down Expand Up @@ -364,7 +362,7 @@ private void renameToFinal(FileSystem fs, Path src, Path dst, int nextVersion) {
"Failed to acquire lock on file: %s with owner: %s", dst, src);
}

if (fs.exists(dst)) {
if (io().newInputFile(dst.toString()).exists()) {
CommitFailedException cfe =
new CommitFailedException("Version %d already exists: %s", nextVersion, dst);
RuntimeException re = tryDelete(src);
Expand Down

0 comments on commit f7995d5

Please sign in to comment.