瀏覽代碼

修改缓存 bug, 更新 test 环境配置

reghao 2 年之前
父節點
當前提交
9d22a03aa7

+ 2 - 1
dfs-store/src/main/java/cn/reghao/dfs/store/service/ObjectBasicService.java

@@ -20,6 +20,7 @@ import java.nio.channels.FileChannel;
 import java.nio.channels.WritableByteChannel;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
@@ -235,7 +236,7 @@ public class ObjectBasicService {
         OutputStream outputStream = response.getOutputStream();
         RandomAccessFile raf;
         String cachePath = localCache.getCache(objectId);
-        if (cachePath != null) {
+        if (cachePath != null && Files.exists(Path.of(cachePath))) {
             raf = new RandomAccessFile(cachePath, "r");
         } else {
             List<DataBlock> list = dataBlockMapper.findByObjectId(objectId);

+ 8 - 2
dfs-store/src/main/resources/application-dev1.yml

@@ -1,7 +1,12 @@
 dubbo:
   registry:
-    address: zookeeper://localhost:2181
+    address: zookeeper://127.0.0.1:2181
 spring:
+  redis:
+    database: 0
+    host: 127.0.0.1
+    port: 6379
+    password: Dev@123456
   datasource:
     url: jdbc:mysql://localhost:3306/reghao_oss_rdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8
     username: dev
@@ -13,4 +18,5 @@ dfs:
   baseDirs:
     - /opt/oss/disk/00b989fc-991b-4d4e-959e-9b6e19299b72/
   encryptKey: 5JCdi68CulSDu0TqD4jR
-  metaDir: /opt/oss/meta
+  metaDir: /opt/oss/meta
+  cacheDir: /opt/oss/cache

+ 2 - 1
dfs-store/src/main/resources/application-test.yml

@@ -13,4 +13,5 @@ dfs:
   baseDirs:
     - /opt/oss/disk/13f654c8-af87-4710-aac9-7aa086c99aec/
   encryptKey: 5JCdi68CulSDu0TqD4jR
-  metaDir: /opt/oss/meta
+  metaDir: /opt/oss/meta
+  cacheDir: /opt/oss/cache