From 2ab2662fcd945f13679411e3a534b8bd4aa4cbba Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Thu, 21 Apr 2022 13:58:54 +0800 Subject: [PATCH] fix: cannot upload file to onedrive because file info not match (fix #1215) Path in onedrive is not case-sensitive while Cloudreve cares, thus file size is not matching when finishing upload. --- assets | 2 +- pkg/filesystem/manage.go | 6 +++++- service/callback/upload.go | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/assets b/assets index 335880b..f2e1195 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 335880b776326f9f0fcf1c4b3d99d4cfb82303b3 +Subproject commit f2e11958738434c5a14547f21b6e78d7f3aec6fe diff --git a/pkg/filesystem/manage.go b/pkg/filesystem/manage.go index 97050ef..724b250 100644 --- a/pkg/filesystem/manage.go +++ b/pkg/filesystem/manage.go @@ -379,10 +379,14 @@ func (fs *FileSystem) listObjects(ctx context.Context, parent string, files []mo // CreateDirectory 根据给定的完整创建目录,支持递归创建。如果目录已存在,则直接 // 返回已存在的目录。 func (fs *FileSystem) CreateDirectory(ctx context.Context, fullPath string) (*model.Folder, error) { - if fullPath == "/" || fullPath == "." || fullPath == "" { + if fullPath == "." || fullPath == "" { return nil, ErrRootProtected } + if fullPath == "/" { + return fs.User.Root() + } + // 获取要创建目录的父路径和目录名 fullPath = path.Clean(fullPath) base := path.Dir(fullPath) diff --git a/service/callback/upload.go b/service/callback/upload.go index fb94675..fcb3f49 100644 --- a/service/callback/upload.go +++ b/service/callback/upload.go @@ -179,7 +179,7 @@ func (service *OneDriveCallback) PreProcess(c *gin.Context) serializer.Response isSizeCheckFailed = false } - if isSizeCheckFailed || info.GetSourcePath() != actualPath { + if isSizeCheckFailed || !strings.EqualFold(info.GetSourcePath(), actualPath) { fs.Handler.(onedrive.Driver).Client.Delete(context.Background(), []string{info.GetSourcePath()}) return serializer.Err(serializer.CodeUploadFailed, "文件信息不一致", err) }