diff --git a/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java b/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java index 6fcb290..6a25448 100644 --- a/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java +++ b/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java @@ -101,7 +101,10 @@ public class S3ResourceRepository extends BaseResourceRepository { } catch (Exception e) { LogKit.info("{} not exist!", path); } - + if (!path.endsWith(DELIMITER)) { + path = path + DELIMITER; + return getEntry(path); + } return null; } @@ -409,16 +412,11 @@ public class S3ResourceRepository extends BaseResourceRepository { @Override public boolean isDirectory(String path) { - if (path.endsWith(DELIMITER)) { - return exist(path); + if (!path.endsWith(DELIMITER) && fileExist(path)) { + //是文件 + return false; } else { - ObjectListing listing = s3.listObjects(bucket, path); - List objectSummaries = listing.getObjectSummaries(); - if (objectSummaries.isEmpty()) { - return false; - } - String dirFormat = path + DELIMITER; - return objectSummaries.stream().anyMatch(s3ObjectSummary -> StringUtils.equals(s3ObjectSummary.getKey(), dirFormat)); + return dirExist(path) || isParentPathAbsent(path); } }