Browse Source

Pull request #14: DEC-17013 fix: 【S3插件】备份模板很慢,有生成多余文件,后台很多警告

Merge in PG/plugin-repository-s3 from ~FENG/plugin-repository-s3:release/10.0 to release/10.0

* commit '41d31de6e601e188c83d964448739fb680d5a13d':
  DEC-16997 fix: 【S3插件】定时调度的结果文件预览失败
  DEC-17013 fix: 【S3插件】备份模板很慢,有生成多余文件,后台很多警告
persist/10.0
Feng 4 years ago
parent
commit
a56cdef22c
  1. 3
      plugin.xml
  2. 29
      src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java

3
plugin.xml

@ -5,12 +5,13 @@
<main-package>com.fanruan.fs</main-package>
<active>yes</active>
<hidden>no</hidden>
<version>1.2.4</version>
<version>1.2.5</version>
<env-version>10.0</env-version>
<jartime>2020-01-27</jartime>
<vendor>richie</vendor>
<description><![CDATA[使用支持S3协议的云存储文件系统作为文件服务器。]]></description>
<change-notes><![CDATA[
[2021-01-28]修复备份还原S3报警告问题。<br/>
[2021-01-24]修复定时调度结果文件预览失败。<br/>
[2021-01-20]正式作为官方插件维护。<br/>
[2020-12-16]修复远程设计新增、修改模板问题。<br/>

29
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;
}

Loading…
Cancel
Save