diff --git a/src/main/java/com/yutou/nas/NasApplication.java b/src/main/java/com/yutou/nas/NasApplication.java index b73ffcd..12579eb 100644 --- a/src/main/java/com/yutou/nas/NasApplication.java +++ b/src/main/java/com/yutou/nas/NasApplication.java @@ -12,7 +12,7 @@ import org.springframework.context.annotation.Import; @Import(BTDownloadManager.class) @SpringBootApplication public class NasApplication { - public static final String version="1.1.5.1"; + public static final String version="1.1.6"; public static void main(String[] args) { SpringApplication.run(NasApplication.class, args); AppData.defaultMusicPath = (String) ConfigTools.load(ConfigTools.CONFIG, "musicDir"); diff --git a/src/main/java/com/yutou/nas/utils/OSSManager.java b/src/main/java/com/yutou/nas/utils/OSSManager.java index 915ec57..0d2e442 100644 --- a/src/main/java/com/yutou/nas/utils/OSSManager.java +++ b/src/main/java/com/yutou/nas/utils/OSSManager.java @@ -78,11 +78,18 @@ public class OSSManager { uploadPath = uploadPath.substring(1); } String md5 = BinaryUtil.toBase64String(Tools.getFileMD5Byte(file)); + String redisMd5=RedisTools.get(file.getAbsolutePath(),RedisTools.DATABASES_ALI_OSS); + if(!StringUtils.isEmpty(redisMd5)){ + if(redisMd5.equals(md5)){ + Log.i("OSS", "[本地]文件已存在:" + file.getName()); + continue; + } + } if (isExist(client, ConfigTools.load(ConfigTools.CONFIG, type, String.class), uploadPath, md5)) { Log.i("OSS", "文件已存在:" + file.getName()); + RedisTools.set(RedisTools.DATABASES_ALI_OSS,file.getAbsolutePath(),md5); continue; } - Log.i("OSS", "即将上传:" + file.getName()); //client.putObject(ConfigTools.load(ConfigTools.CONFIG,type,String.class), uploadPath, file); int limitSpeed = 1024 * 1024 * 8; ObjectMetadata metadata = new ObjectMetadata(); @@ -113,6 +120,7 @@ public class OSSManager { });*/ client.putObject(request); Log.i("OSS", file.getName() + "已上传"); + RedisTools.set(RedisTools.DATABASES_ALI_OSS,file.getAbsolutePath(),md5); } } catch (Exception e) { diff --git a/src/main/java/com/yutou/nas/utils/RedisTools.java b/src/main/java/com/yutou/nas/utils/RedisTools.java index fecff0d..4771b2e 100644 --- a/src/main/java/com/yutou/nas/utils/RedisTools.java +++ b/src/main/java/com/yutou/nas/utils/RedisTools.java @@ -19,6 +19,7 @@ public class RedisTools { private static String host; private static int port; public static int TOKEN_TIMEOUT_DEFAULT = 360; + public final static int DATABASES_ALI_OSS=4; private RedisTools() {