Skip to content

Commit

Permalink
revert create file overwrite optimize code due to cos list limit (#129)
Browse files Browse the repository at this point in the history
Signed-off-by: liuyongqing <815331793@qq.com>
Co-authored-by: yongqingliu <yongqingliu@tencent.com>
  • Loading branch information
liuyongqing and yongqingliu committed Dec 1, 2023
1 parent c821406 commit eb15a34
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
9 changes: 2 additions & 7 deletions src/main/java/org/apache/hadoop/fs/CosNFileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public FSDataOutputStream create(Path f, FsPermission permission,
if (createOpCheckExistFile) {
// preconditions
try {
FileStatus targetFileStatus = this.innerGetFileStatus(f, !overwrite);
FileStatus targetFileStatus = this.getFileStatus(f);
if (targetFileStatus.isSymlink()) {
f = this.getLinkTarget(f);
// call the getFileStatus for the latest path again.
Expand Down Expand Up @@ -560,12 +560,7 @@ private void internalAutoRecursiveDelete(String key) throws IOException {
this.nativeStore.deleteRecursive(key);
}

@Override
public FileStatus getFileStatus(Path f) throws IOException {
return innerGetFileStatus(f, true);
}

public FileStatus innerGetFileStatus(Path f, boolean checkFile) throws IOException {

Path absolutePath = makeAbsolute(f);
String key = pathToKey(absolutePath);
Expand All @@ -575,7 +570,7 @@ public FileStatus innerGetFileStatus(Path f, boolean checkFile) throws IOExcepti
}

CosNResultInfo getObjectMetadataResultInfo = new CosNResultInfo();
FileMetadata meta = this.nativeStore.retrieveMetadata(key, getObjectMetadataResultInfo, checkFile);
FileMetadata meta = this.nativeStore.retrieveMetadata(key, getObjectMetadataResultInfo);
if (meta != null) {
if (meta.isFile()) {
LOG.debug("Retrieve the cos key [{}] to find that it is a file.", key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -846,18 +846,18 @@ private FileMetadata queryObjectMetadata(String key,

@Override
public FileMetadata retrieveMetadata(String key) throws IOException {
return retrieveMetadata(key, null, true);
return retrieveMetadata(key, null);
}

// this method only used in getFileStatus to get the head request result info
@Override
public FileMetadata retrieveMetadata(String key,
CosNResultInfo info, boolean checkFile) throws IOException {
CosNResultInfo info) throws IOException {
if (key.endsWith(CosNFileSystem.PATH_DELIMITER)) {
key = key.substring(0, key.length() - 1);
}

if (!key.isEmpty() && checkFile) {
if (!key.isEmpty()) {
FileMetadata fileMetadata = queryObjectMetadata(key, info);
if (fileMetadata != null) {
return fileMetadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ PartETag uploadPartCopy(String uploadId, String srcKey, String destKey, int part

FileMetadata retrieveMetadata(String key) throws IOException;

FileMetadata retrieveMetadata(String key, CosNResultInfo info, boolean checkFile) throws IOException;
FileMetadata retrieveMetadata(String key, CosNResultInfo info) throws IOException;

CosNSymlinkMetadata retrieveSymlinkMetadata(String symlink) throws IOException;

Expand Down

0 comments on commit eb15a34

Please sign in to comment.