From 893bbae5b492ba3fc316f08ce7702d2834b3d3b1 Mon Sep 17 00:00:00 2001 From: Feng Date: Thu, 28 Jan 2021 16:52:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?DEC-17013=20fix:=20=E3=80=90S3=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E3=80=91=E5=A4=87=E4=BB=BD=E6=A8=A1=E6=9D=BF=E5=BE=88?= =?UTF-8?q?=E6=85=A2=EF=BC=8C=E6=9C=89=E7=94=9F=E6=88=90=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E5=90=8E=E5=8F=B0=E5=BE=88=E5=A4=9A?= =?UTF-8?q?=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/core/S3ResourceRepository.java | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) 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 9c18ead..341bd25 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 @@ -19,7 +19,6 @@ import com.fanruan.api.util.StringKit; import com.fr.io.repository.FineFileEntry; import com.fr.io.repository.base.BaseResourceRepository; import com.fr.stable.Filter; -import com.fr.stable.StringUtils; import com.fr.workspace.resource.ResourceIOException; import java.io.ByteArrayInputStream; @@ -58,11 +57,9 @@ public class S3ResourceRepository extends BaseResourceRepository { @Override public FineFileEntry getEntry(String path) { - GetObjectRequest request = new GetObjectRequest(bucket, path); try { - try (S3Object s3Object = s3.getObject(request)) { - return s3Object2FileEntry(s3Object, path); - } + ObjectMetadata metadata = s3.getObjectMetadata(bucket, path); + return s3Object2FileEntry(metadata, path); } catch (Exception e) { LogKit.info("{} not exist!", path); } @@ -225,7 +222,7 @@ public class S3ResourceRepository extends BaseResourceRepository { for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { String key = objectSummary.getKey(); - if (StringUtils.equals(key, dir)) { + if (StringKit.equals(key, dir)) { continue; } String[] arr = key.split(DELIMITER); @@ -291,14 +288,8 @@ public class S3ResourceRepository extends BaseResourceRepository { @Override public long length(String path) { try { - S3Object s3Object = s3.getObject(bucket, path); - if (s3Object != null) { - try { - return s3Object.getObjectMetadata().getContentLength(); - } finally { - s3Object.close(); - } - } + ObjectMetadata metadata = s3.getObjectMetadata(bucket, path); + return metadata.getContentLength(); } catch (Exception e) { LogKit.info("{} not exist!", path); } @@ -342,17 +333,17 @@ public class S3ResourceRepository extends BaseResourceRepository { private FineFileEntry s3Object2FileEntry(S3ObjectSummary s3Object, String path) { FineFileEntry entry = new FineFileEntry(path); - entry.setDirectory(s3Object.getKey().endsWith("/")); + entry.setDirectory(s3Object.getKey().endsWith(DELIMITER)); entry.setSize(s3Object.getSize()); entry.setTimestamp(s3Object.getLastModified().getTime()); return entry; } - private FineFileEntry s3Object2FileEntry(S3Object s3Object, String path) { + private FineFileEntry s3Object2FileEntry(ObjectMetadata metadata, String path) { FineFileEntry entry = new FineFileEntry(path); - entry.setDirectory(s3Object.getKey().endsWith("/")); - entry.setSize(s3Object.getObjectMetadata().getContentLength()); - entry.setTimestamp(s3Object.getObjectMetadata().getLastModified().getTime()); + entry.setDirectory(path.endsWith(DELIMITER)); + entry.setSize(metadata.getContentLength()); + entry.setTimestamp(metadata.getLastModified().getTime()); return entry; } From 41d31de6e601e188c83d964448739fb680d5a13d Mon Sep 17 00:00:00 2001 From: Feng Date: Thu, 28 Jan 2021 16:54:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?DEC-16997=20fix:=20=E3=80=90S3=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E3=80=91=E5=AE=9A=E6=97=B6=E8=B0=83=E5=BA=A6=E7=9A=84?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E6=96=87=E4=BB=B6=E9=A2=84=E8=A7=88=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 1bff9bd..279fa25 100644 --- a/plugin.xml +++ b/plugin.xml @@ -5,12 +5,13 @@ com.fanruan.fs yes no - 1.2.4 + 1.2.5 10.0 2020-01-27 richie [2021-01-24]修复定时调度结果文件预览失败。
[2021-01-20]正式作为官方插件维护。
[2020-12-16]修复远程设计新增、修改模板问题。