From f3decc21ffc38c262ed34a3b0f15a8bffe2988d6 Mon Sep 17 00:00:00 2001 From: zhouxin Date: Sat, 22 May 2021 21:24:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zxbu/webdavteambition/model/UploadPreRequest.java | 2 +- .../store/AliYunDriverClientService.java | 9 ++++++++- .../store/AliYunDriverFileSystemStore.java | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/zxbu/webdavteambition/model/UploadPreRequest.java b/src/main/java/com/github/zxbu/webdavteambition/model/UploadPreRequest.java index 679ccb6..c569b2e 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/model/UploadPreRequest.java +++ b/src/main/java/com/github/zxbu/webdavteambition/model/UploadPreRequest.java @@ -5,7 +5,7 @@ import java.util.List; public class UploadPreRequest { private String check_name_mode = "refuse"; private String content_hash; - private String content_hash_name = "sha1"; + private String content_hash_name = "none"; private String drive_id; private String name; private String parent_file_id; diff --git a/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java b/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java index 523aa86..a2905fd 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java +++ b/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java @@ -93,10 +93,17 @@ public class AliYunDriverClientService { if (parent == null) { return; } + // 如果已存在,先删除 + TFile tfile = getTFileByPath(path); + if (tfile != null) { + remove(path); + } + + int chunkCount = (int) Math.ceil(((double) size) / chunkSize); // 进1法 UploadPreRequest uploadPreRequest = new UploadPreRequest(); - uploadPreRequest.setContent_hash(UUID.randomUUID().toString()); +// uploadPreRequest.setContent_hash(UUID.randomUUID().toString()); uploadPreRequest.setDrive_id(client.getDriveId()); uploadPreRequest.setName(pathInfo.getName()); uploadPreRequest.setParent_file_id(parent.getFile_id()); diff --git a/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverFileSystemStore.java b/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverFileSystemStore.java index 3ab9dba..69cfc6e 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverFileSystemStore.java +++ b/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverFileSystemStore.java @@ -1,5 +1,6 @@ package com.github.zxbu.webdavteambition.store; +import com.github.zxbu.webdavteambition.model.FileType; import com.github.zxbu.webdavteambition.model.PathInfo; import com.github.zxbu.webdavteambition.model.result.TFile; import net.sf.webdav.ITransaction; @@ -107,6 +108,9 @@ public class AliYunDriverFileSystemStore implements IWebdavStore { public String[] getChildrenNames(ITransaction transaction, String folderUri) { LOGGER.debug("getChildrenNames: {}", folderUri); TFile tFile = aliYunDriverClientService.getTFileByPath(folderUri); + if (tFile.getType().equals(FileType.file.name())) { + return new String[0]; + } Set tFileList = aliYunDriverClientService.getTFiles(tFile.getFile_id()); return tFileList.stream().map(TFile::getName).toArray(String[]::new); }