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]修复远程设计新增、修改模板问题。
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;
}