Feat: mount storage policy for folders in WebDAV

This commit is contained in:
HFO4
2020-02-13 15:27:40 +08:00
parent a0a9686959
commit 44d6ca487c
13 changed files with 76 additions and 12 deletions

View File

@@ -113,6 +113,10 @@ func (handler Driver) Delete(ctx context.Context, files []string) ([]string, err
failed = append(failed, v.Key)
}
if len(failed) == 0 {
return failed, nil
}
return failed, errors.New("删除失败")
}

View File

@@ -190,6 +190,9 @@ func (fs *FileSystem) Delete(ctx context.Context, dirs, files []uint) error {
return ErrDBDeleteObjects.WithError(err)
}
// 删除文件记录对应的分享记录
model.DeleteShareBySourceIDs(allFileIDs, false)
// 归还容量
var total uint64
for _, value := range totalStorage {
@@ -207,6 +210,9 @@ func (fs *FileSystem) Delete(ctx context.Context, dirs, files []uint) error {
return ErrDBDeleteObjects.WithError(err)
}
// 删除目录记录对应的分享记录
model.DeleteShareBySourceIDs(allFolderIDs, true)
if notDeleted := len(fs.FileTarget) - len(deletedFileIDs); notDeleted > 0 {
return serializer.NewError(
serializer.CodeNotFullySuccess,

View File

@@ -172,7 +172,7 @@ func (fs *FileSystem) GetUploadToken(ctx context.Context, path string, size uint
serializer.UploadSession{
Key: callbackKey,
UID: fs.User.ID,
PolicyID: fs.User.GetPolicyID(),
PolicyID: fs.User.GetPolicyID(0),
VirtualPath: path,
Name: name,
Size: size,