i18n: objects / share / slave / tag operations

pull/1416/head
HFO4 2 years ago
parent 906e9857bc
commit 96daed26b4

@ -22,4 +22,5 @@ var (
ErrIO = serializer.NewError(serializer.CodeIOFailed, "Failed to read file data", nil)
ErrDBListObjects = serializer.NewError(serializer.CodeDBError, "Failed to list object records", nil)
ErrDBDeleteObjects = serializer.NewError(serializer.CodeDBError, "Failed to delete object records", nil)
ErrOneObjectOnly = serializer.ParamErr("You can only copy one object at the same time", nil)
)

@ -73,7 +73,7 @@ func (fs *FileSystem) Copy(ctx context.Context, dirs, files []uint, src, dst str
if len(dirs) > 0 {
subFileSizes, err := srcFolder.CopyFolderTo(dirs[0], dstFolder)
if err != nil {
return serializer.NewError(serializer.CodeDBError, "操作失败,可能有重名冲突", err)
return ErrObjectNotExist.WithError(err)
}
newUsedStorage += subFileSizes
}
@ -82,7 +82,7 @@ func (fs *FileSystem) Copy(ctx context.Context, dirs, files []uint, src, dst str
if len(files) > 0 {
subFileSizes, err := srcFolder.MoveOrCopyFileTo(files, dstFolder, true)
if err != nil {
return serializer.NewError(serializer.CodeDBError, "操作失败,可能有重名冲突", err)
return ErrObjectNotExist.WithError(err)
}
newUsedStorage += subFileSizes
}
@ -106,13 +106,13 @@ func (fs *FileSystem) Move(ctx context.Context, dirs, files []uint, src, dst str
// 处理目录及子文件移动
err := srcFolder.MoveFolderTo(dirs, dstFolder)
if err != nil {
return serializer.NewError(serializer.CodeDBError, "操作失败,可能有重名冲突", err)
return ErrFileExisted.WithError(err)
}
// 处理文件移动
_, err = srcFolder.MoveOrCopyFileTo(files, dstFolder, false)
if err != nil {
return serializer.NewError(serializer.CodeDBError, "操作失败,可能有重名冲突", err)
return ErrFileExisted.WithError(err)
}
// 移动文件

@ -164,6 +164,14 @@ const (
CodeUnsupportedArchiveType = 40056
// 可用存储策略发生变化
CodePolicyChanged = 40057
// 分享链接无效
CodeShareLinkNotFound = 40058
// 不能转存自己的分享
CodeSaveOwnShare = 40059
// 从机无法向主机发送回调请求
CodeSlavePingMaster = 40060
// Cloudreve 版本不一致
CodeVersionMismatch = 40061
// CodeDBError 数据库操作失败
CodeDBError = 50001
// CodeEncryptError 加密失败

@ -142,13 +142,13 @@ func PreviewShareReadme(c *gin.Context) {
allowFileName := []string{"readme.txt", "readme.md"}
fileName := strings.ToLower(path.Base(service.Path))
if !util.ContainsString(allowFileName, fileName) {
c.JSON(200, serializer.ParamErr("非README文件", nil))
c.JSON(200, serializer.ParamErr("Not a README file", nil))
}
// 必须是目录分享
if shareCtx, ok := c.Get("share"); ok {
if !shareCtx.(*model.Share).IsDir {
c.JSON(200, serializer.ParamErr("此分享无自述文件", nil))
c.JSON(200, serializer.ParamErr("This share has no README file", nil))
}
}

@ -194,7 +194,7 @@ func (service *PolicyService) AddCORS() serializer.Response {
func (service *SlavePingService) Test() serializer.Response {
master, err := url.Parse(service.Callback)
if err != nil {
return serializer.ParamErr("无法解析主机站点地址,请检查主机 参数设置 - 站点信息 - 站点URL设置"+err.Error(), nil)
return serializer.ParamErr("Failed to parse Master site url: "+err.Error(), nil)
}
controller, _ := url.Parse("/api/v3/site/ping")
@ -208,7 +208,7 @@ func (service *SlavePingService) Test() serializer.Response {
).DecodeResponse()
if err != nil {
return serializer.ParamErr("从机无法向主机发送回调请求,请检查主机端 参数设置 - 站点信息 - 站点URL设置并确保从机可以连接到此地址"+err.Error(), nil)
return serializer.Err(serializer.CodeSlavePingMaster, err.Error(), nil)
}
version := conf.BackendVersion
@ -216,7 +216,7 @@ func (service *SlavePingService) Test() serializer.Response {
version += "-pro"
}
if res.Data.(string) != version {
return serializer.ParamErr("Cloudreve版本不一致主机"+res.Data.(string)+",从机:"+version, nil)
return serializer.Err(serializer.CodeVersionMismatch, "Master: "+res.Data.(string)+", Slave: "+version, nil)
}
return serializer.Response{}

@ -136,14 +136,14 @@ func Add(c *gin.Context, service *serializer.SlaveAria2Call) serializer.Response
// 创建任务
gid, err := caller.(common.Aria2).CreateTask(service.Task, service.GroupOptions)
if err != nil {
return serializer.Err(serializer.CodeInternalSetting, "无法创建离线下载任务", err)
return serializer.Err(serializer.CodeInternalSetting, "Failed to create aria2 task", err)
}
// 创建事件通知回调
siteID, _ := c.Get("MasterSiteID")
mq.GlobalMQ.SubscribeCallback(gid, func(message mq.Message) {
if err := cluster.DefaultController.SendNotification(siteID.(string), message.TriggeredBy, message); err != nil {
util.Log().Warning("无法发送离线下载任务状态变更通知, %s", err)
util.Log().Warning("Failed to send remote download task status change notifications: %s", err)
}
})

@ -110,7 +110,7 @@ func SlaveStatus(c *gin.Context, service *serializer.SlaveAria2Call) serializer.
// 查询任务
status, err := caller.(common.Aria2).Status(service.Task)
if err != nil {
return serializer.Err(serializer.CodeInternalSetting, "离线下载任务查询失败", err)
return serializer.Err(serializer.CodeInternalSetting, "Failed to query remote download task status", err)
}
return serializer.NewResponseWithGobData(status)
@ -124,7 +124,7 @@ func SlaveCancel(c *gin.Context, service *serializer.SlaveAria2Call) serializer.
// 查询任务
err := caller.(common.Aria2).Cancel(service.Task)
if err != nil {
return serializer.Err(serializer.CodeInternalSetting, "任务取消失败", err)
return serializer.Err(serializer.CodeInternalSetting, "Failed to cancel task", err)
}
return serializer.Response{}
@ -138,7 +138,7 @@ func SlaveSelect(c *gin.Context, service *serializer.SlaveAria2Call) serializer.
// 查询任务
err := caller.(common.Aria2).Select(service.Task, service.Files)
if err != nil {
return serializer.Err(serializer.CodeInternalSetting, "任务选取失败", err)
return serializer.Err(serializer.CodeInternalSetting, "Failed to select files", err)
}
return serializer.Response{}
@ -152,7 +152,7 @@ func SlaveDeleteTemp(c *gin.Context, service *serializer.SlaveAria2Call) seriali
// 查询任务
err := caller.(common.Aria2).DeleteTempFile(service.Task)
if err != nil {
return serializer.Err(serializer.CodeInternalSetting, "临时文件删除失败", err)
return serializer.Err(serializer.CodeInternalSetting, "Failed to delete temp files", err)
}
return serializer.Response{}

@ -84,13 +84,13 @@ func (service *SlaveListService) List(c *gin.Context) serializer.Response {
// 创建文件系统
fs, err := filesystem.NewAnonymousFileSystem()
if err != nil {
return serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err)
return serializer.Err(serializer.CodeCreateFSError, "", err)
}
defer fs.Recycle()
objects, err := fs.Handler.List(context.Background(), service.Path, service.Recursive)
if err != nil {
return serializer.Err(serializer.CodeIOFailed, "无法列取文件", err)
return serializer.Err(serializer.CodeIOFailed, "Cannot list files", err)
}
res, _ := json.Marshal(objects)

@ -290,7 +290,7 @@ func (service *ItemMoveService) Move(ctx context.Context, c *gin.Context) serial
// 创建文件系统
fs, err := filesystem.NewFileSystemFromContext(c)
if err != nil {
return serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err)
return serializer.Err(serializer.CodeCreateFSError, "", err)
}
defer fs.Recycle()
@ -311,13 +311,13 @@ func (service *ItemMoveService) Move(ctx context.Context, c *gin.Context) serial
func (service *ItemMoveService) Copy(ctx context.Context, c *gin.Context) serializer.Response {
// 复制操作只能对一个目录或文件对象进行操作
if len(service.Src.Items)+len(service.Src.Dirs) > 1 {
return serializer.ParamErr("只能复制一个对象", nil)
return filesystem.ErrOneObjectOnly
}
// 创建文件系统
fs, err := filesystem.NewFileSystemFromContext(c)
if err != nil {
return serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err)
return serializer.Err(serializer.CodeCreateFSError, "", err)
}
defer fs.Recycle()
@ -337,13 +337,13 @@ func (service *ItemMoveService) Copy(ctx context.Context, c *gin.Context) serial
func (service *ItemRenameService) Rename(ctx context.Context, c *gin.Context) serializer.Response {
// 重命名作只能对一个目录或文件对象进行操作
if len(service.Src.Items)+len(service.Src.Dirs) > 1 {
return serializer.ParamErr("只能操作一个对象", nil)
return filesystem.ErrOneObjectOnly
}
// 创建文件系统
fs, err := filesystem.NewFileSystemFromContext(c)
if err != nil {
return serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err)
return serializer.Err(serializer.CodeCreateFSError, "", err)
}
defer fs.Recycle()
@ -370,12 +370,12 @@ func (service *ItemPropertyService) GetProperty(ctx context.Context, c *gin.Cont
if !service.IsFolder {
res, err := hashid.DecodeHashID(service.ID, hashid.FileID)
if err != nil {
return serializer.Err(serializer.CodeNotFound, "对象不存在", err)
return serializer.Err(serializer.CodeNotFound, "", err)
}
file, err := model.GetFilesByIDs([]uint{res}, user.ID)
if err != nil {
return serializer.DBErr("找不到文件", err)
return serializer.DBErr("Failed to query file records", err)
}
props.CreatedAt = file[0].CreatedAt
@ -387,11 +387,11 @@ func (service *ItemPropertyService) GetProperty(ctx context.Context, c *gin.Cont
if service.TraceRoot {
parent, err := model.GetFoldersByIDs([]uint{file[0].FolderID}, user.ID)
if err != nil {
return serializer.DBErr("找不到父目录", err)
return serializer.DBErr("Parent folder record not exist", err)
}
if err := parent[0].TraceRoot(); err != nil {
return serializer.DBErr("无法溯源父目录", err)
return serializer.DBErr("Failed to trace root folder", err)
}
props.Path = path.Join(parent[0].Position, parent[0].Name)
@ -399,12 +399,12 @@ func (service *ItemPropertyService) GetProperty(ctx context.Context, c *gin.Cont
} else {
res, err := hashid.DecodeHashID(service.ID, hashid.FolderID)
if err != nil {
return serializer.Err(serializer.CodeNotFound, "对象不存在", err)
return serializer.Err(serializer.CodeNotFound, "", err)
}
folder, err := model.GetFoldersByIDs([]uint{res}, user.ID)
if err != nil {
return serializer.DBErr("找不到目录", err)
return serializer.DBErr("Failed to query folder records", err)
}
props.CreatedAt = folder[0].CreatedAt
@ -422,14 +422,14 @@ func (service *ItemPropertyService) GetProperty(ctx context.Context, c *gin.Cont
childFolders, err := model.GetRecursiveChildFolder([]uint{folder[0].ID},
user.ID, true)
if err != nil {
return serializer.DBErr("无法列取子目录", err)
return serializer.DBErr("Failed to list child folders", err)
}
props.ChildFolderNum = len(childFolders) - 1
// 统计子文件
files, err := model.GetChildFilesOfFolders(&childFolders)
if err != nil {
return serializer.DBErr("无法列取子文件", err)
return serializer.DBErr("Failed to list child files", err)
}
// 统计子文件个数和大小
@ -441,7 +441,7 @@ func (service *ItemPropertyService) GetProperty(ctx context.Context, c *gin.Cont
// 查找父目录
if service.TraceRoot {
if err := folder[0].TraceRoot(); err != nil {
return serializer.DBErr("无法溯源父目录", err)
return serializer.DBErr("Failed to list child folders", err)
}
props.Path = folder[0].Position

@ -49,14 +49,14 @@ func (service *SlaveDownloadService) ServeFile(ctx context.Context, c *gin.Conte
// 创建文件系统
fs, err := filesystem.NewAnonymousFileSystem()
if err != nil {
return serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err)
return serializer.Err(serializer.CodeCreateFSError, "", err)
}
defer fs.Recycle()
// 解码文件路径
fileSource, err := base64.RawURLEncoding.DecodeString(service.PathEncoded)
if err != nil {
return serializer.ParamErr("无法解析的文件地址", err)
return serializer.Err(serializer.CodeFileNotFound, "", err)
}
// 根据URL里的信息创建一个文件对象和用户对象
@ -97,7 +97,7 @@ func (service *SlaveFilesService) Delete(ctx context.Context, c *gin.Context) se
// 创建文件系统
fs, err := filesystem.NewAnonymousFileSystem()
if err != nil {
return serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err)
return serializer.Err(serializer.CodeCreateFSError, "", err)
}
defer fs.Recycle()
@ -110,7 +110,7 @@ func (service *SlaveFilesService) Delete(ctx context.Context, c *gin.Context) se
return serializer.Response{
Code: serializer.CodeNotFullySuccess,
Data: string(data),
Msg: fmt.Sprintf("有 %d 个文件未能成功删除", len(failed)),
Msg: fmt.Sprintf("Failed to delete %d files(s)", len(failed)),
Error: err.Error(),
}
}
@ -122,21 +122,21 @@ func (service *SlaveFileService) Thumb(ctx context.Context, c *gin.Context) seri
// 创建文件系统
fs, err := filesystem.NewAnonymousFileSystem()
if err != nil {
return serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err)
return serializer.Err(serializer.CodeCreateFSError, "", err)
}
defer fs.Recycle()
// 解码文件路径
fileSource, err := base64.RawURLEncoding.DecodeString(service.PathEncoded)
if err != nil {
return serializer.ParamErr("无法解析的文件地址", err)
return serializer.Err(serializer.CodeFileNotFound, "", err)
}
fs.FileTarget = []model.File{{SourceName: string(fileSource), PicInfo: "1,1"}}
// 获取缩略图
resp, err := fs.GetThumb(ctx, 0)
if err != nil {
return serializer.Err(serializer.CodeNotSet, "无法获取缩略图", err)
return serializer.Err(serializer.CodeNotSet, "Failed to get thumb", err)
}
defer resp.Content.Close()
@ -156,7 +156,7 @@ func CreateTransferTask(c *gin.Context, req *serializer.SlaveTransferReq) serial
if err := cluster.DefaultController.SubmitTask(job.MasterID, job, req.Hash(job.MasterID), func(job interface{}) {
task.TaskPoll.Submit(job.(task.Job))
}); err != nil {
return serializer.Err(serializer.CodeInternalSetting, "任务创建失败", err)
return serializer.Err(serializer.CodeCreateTaskError, "", err)
}
return serializer.Response{}

@ -32,7 +32,7 @@ type TagService struct {
func (service *TagService) Delete(c *gin.Context, user *model.User) serializer.Response {
id, _ := c.Get("object_id")
if err := model.DeleteTagByID(id.(uint), user.ID); err != nil {
return serializer.Err(serializer.CodeDBError, "Failed to delete a tag", err)
return serializer.DBErr("Failed to delete a tag", err)
}
return serializer.Response{}
}
@ -49,7 +49,7 @@ func (service *LinkTagCreateService) Create(c *gin.Context, user *model.User) se
}
id, err := tag.Create()
if err != nil {
return serializer.Err(serializer.CodeDBError, "Failed to create a tag", err)
return serializer.DBErr("Failed to create a tag", err)
}
return serializer.Response{
@ -79,7 +79,7 @@ func (service *FilterTagCreateService) Create(c *gin.Context, user *model.User)
}
id, err := tag.Create()
if err != nil {
return serializer.Err(serializer.CodeDBError, "Failed to create a tag", err)
return serializer.DBErr("Failed to create a tag", err)
}
return serializer.Response{

@ -135,7 +135,7 @@ func (service *UploadService) SlaveUpload(ctx context.Context, c *gin.Context) s
fs, err := filesystem.NewAnonymousFileSystem()
if err != nil {
return serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err)
return serializer.Err(serializer.CodeCreateFSError, "", err)
}
fs.Handler = local.Driver{}
@ -249,13 +249,13 @@ func (service *UploadSessionService) SlaveDelete(ctx context.Context, c *gin.Con
// 创建文件系统
fs, err := filesystem.NewAnonymousFileSystem()
if err != nil {
return serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err)
return serializer.Err(serializer.CodeCreateFSError, "", err)
}
defer fs.Recycle()
session, ok := cache.Get(filesystem.UploadSessionCachePrefix + service.ID)
if !ok {
return serializer.Err(serializer.CodeUploadSessionExpired, "Slave Upload session file placeholder not exist", nil)
return serializer.Err(serializer.CodeUploadSessionExpired, "", nil)
}
if _, err := fs.Handler.Delete(ctx, []string{session.(serializer.UploadSession).SavePath}); err != nil {

@ -47,7 +47,7 @@ func (s *SlaveNotificationService) HandleSlaveNotificationPush(c *gin.Context) s
func (s *OneDriveCredentialService) Get(c *gin.Context) serializer.Response {
policy, err := model.GetPolicyByID(s.PolicyID)
if err != nil {
return serializer.Err(serializer.CodeNotFound, "Cannot found storage policy", err)
return serializer.Err(serializer.CodePolicyNotExist, "", err)
}
client, err := onedrive.NewClient(&policy)

@ -30,11 +30,11 @@ type ShareUpdateService struct {
func (service *Service) Delete(c *gin.Context, user *model.User) serializer.Response {
share := model.GetShareByHashID(c.Param("id"))
if share == nil || share.Creator().ID != user.ID {
return serializer.Err(serializer.CodeNotFound, "分享不存在", nil)
return serializer.Err(serializer.CodeShareLinkNotFound, "", nil)
}
if err := share.Delete(); err != nil {
return serializer.Err(serializer.CodeDBError, "分享删除失败", err)
return serializer.DBErr("Failed to delete share record", err)
}
return serializer.Response{}
@ -49,13 +49,13 @@ func (service *ShareUpdateService) Update(c *gin.Context) serializer.Response {
case "password":
err := share.Update(map[string]interface{}{"password": service.Value})
if err != nil {
return serializer.Err(serializer.CodeDBError, "无法更新分享密码", err)
return serializer.DBErr("Failed to update share record", err)
}
case "preview_enabled":
value := service.Value == "true"
err := share.Update(map[string]interface{}{"preview_enabled": value})
if err != nil {
return serializer.Err(serializer.CodeDBError, "无法更新分享属性", err)
return serializer.DBErr("Failed to update share record", err)
}
return serializer.Response{
Data: value,
@ -73,7 +73,7 @@ func (service *ShareCreateService) Create(c *gin.Context) serializer.Response {
// 是否拥有权限
if !user.Group.ShareEnabled {
return serializer.Err(serializer.CodeNoPermissionErr, "您无权创建分享链接", nil)
return serializer.Err(serializer.CodeGroupNotAllowed, "", nil)
}
// 源对象真实ID
@ -88,7 +88,7 @@ func (service *ShareCreateService) Create(c *gin.Context) serializer.Response {
sourceID, err = hashid.DecodeHashID(service.SourceID, hashid.FileID)
}
if err != nil {
return serializer.Err(serializer.CodeNotFound, "原始资源不存在", nil)
return serializer.Err(serializer.CodeNotFound, "", nil)
}
// 对象是否存在
@ -109,7 +109,7 @@ func (service *ShareCreateService) Create(c *gin.Context) serializer.Response {
}
}
if !exist {
return serializer.Err(serializer.CodeNotFound, "原始资源不存在", nil)
return serializer.Err(serializer.CodeNotFound, "", nil)
}
newShare := model.Share{
@ -132,7 +132,7 @@ func (service *ShareCreateService) Create(c *gin.Context) serializer.Response {
// 创建分享
id, err := newShare.Create()
if err != nil {
return serializer.Err(serializer.CodeDBError, "分享链接创建失败", err)
return serializer.DBErr("Failed to create share link record", err)
}
// 获取分享的唯一id

@ -54,7 +54,7 @@ func (service *ShareUserGetService) Get(c *gin.Context) serializer.Response {
userID, _ := c.Get("object_id")
user, err := model.GetActiveUserByID(userID.(uint))
if err != nil || user.OptionsSerialized.ProfileOff {
return serializer.Err(serializer.CodeNotFound, "用户不存在", err)
return serializer.Err(serializer.CodeNotFound, "", err)
}
// 列出分享
@ -153,14 +153,14 @@ func (service *Service) CreateDownloadSession(c *gin.Context) serializer.Respons
// 创建文件系统
fs, err := filesystem.NewFileSystem(user)
if err != nil {
return serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err)
return serializer.DBErr("Failed to update share record", err)
}
defer fs.Recycle()
// 重设文件系统处理目标为源文件
err = fs.SetTargetByInterface(share.Source())
if err != nil {
return serializer.Err(serializer.CodePolicyNotAllowed, "源文件不存在", err)
return serializer.Err(serializer.CodeFileNotFound, "", err)
}
ctx := context.Background()
@ -230,17 +230,17 @@ func (service *Service) List(c *gin.Context) serializer.Response {
share := shareCtx.(*model.Share)
if !share.IsDir {
return serializer.ParamErr("此分享无法列目录", nil)
return serializer.ParamErr("This is not a shared folder", nil)
}
if !path.IsAbs(service.Path) {
return serializer.ParamErr("路径无效", nil)
return serializer.ParamErr("Invalid path", nil)
}
// 创建文件系统
fs, err := filesystem.NewFileSystem(share.Creator())
if err != nil {
return serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err)
return serializer.Err(serializer.CodeCreateFSError, "", err)
}
defer fs.Recycle()
@ -258,7 +258,7 @@ func (service *Service) List(c *gin.Context) serializer.Response {
// 获取子项目
objects, err := fs.List(ctx, service.Path, nil)
if err != nil {
return serializer.Err(serializer.CodeCreateFolderFailed, err.Error(), err)
return serializer.Err(serializer.CodeNotSet, err.Error(), err)
}
return serializer.Response{
@ -273,13 +273,13 @@ func (service *Service) Thumb(c *gin.Context) serializer.Response {
share := shareCtx.(*model.Share)
if !share.IsDir {
return serializer.ParamErr("此分享无缩略图", nil)
return serializer.ParamErr("This share has no thumb", nil)
}
// 创建文件系统
fs, err := filesystem.NewFileSystem(share.Creator())
if err != nil {
return serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err)
return serializer.Err(serializer.CodeCreateFSError, "", err)
}
defer fs.Recycle()
@ -289,7 +289,7 @@ func (service *Service) Thumb(c *gin.Context) serializer.Response {
// 找到缩略图的父目录
exist, parent := fs.IsPathExist(service.Path)
if !exist {
return serializer.Err(serializer.CodeNotFound, "路径不存在", nil)
return serializer.Err(serializer.CodeParentNotExist, "", nil)
}
ctx := context.WithValue(context.Background(), fsctx.LimitParentCtx, parent)
@ -297,13 +297,13 @@ func (service *Service) Thumb(c *gin.Context) serializer.Response {
// 获取文件ID
fileID, err := hashid.DecodeHashID(c.Param("file"), hashid.FileID)
if err != nil {
return serializer.ParamErr("无法解析文件ID", err)
return serializer.Err(serializer.CodeNotFound, "", err)
}
// 获取缩略图
resp, err := fs.GetThumb(ctx, uint(fileID))
if err != nil {
return serializer.Err(serializer.CodeNotSet, "无法获取缩略图", err)
return serializer.Err(serializer.CodeNotSet, "Failed to get thumb", err)
}
if resp.Redirect {
@ -328,17 +328,17 @@ func (service *ArchiveService) Archive(c *gin.Context) serializer.Response {
// 是否有权限
if !user.Group.OptionsSerialized.ArchiveDownload {
return serializer.Err(serializer.CodeNoPermissionErr, "您的用户组无权进行此操作", nil)
return serializer.Err(serializer.CodeGroupNotAllowed, "", nil)
}
if !share.IsDir {
return serializer.ParamErr("此分享无法进行打包", nil)
return serializer.ParamErr("This share cannot be batch downloaded", nil)
}
// 创建文件系统
fs, err := filesystem.NewFileSystem(user)
if err != nil {
return serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err)
return serializer.Err(serializer.CodeCreateFSError, "", err)
}
defer fs.Recycle()
@ -348,7 +348,7 @@ func (service *ArchiveService) Archive(c *gin.Context) serializer.Response {
// 找到要打包文件的父目录
exist, parent := fs.IsPathExist(service.Path)
if !exist {
return serializer.Err(serializer.CodeNotFound, "路径不存在", nil)
return serializer.Err(serializer.CodeParentNotExist, "", nil)
}
// 限制操作范围为父目录下
@ -388,7 +388,7 @@ func (service *SearchService) Search(c *gin.Context) serializer.Response {
// 创建文件系统
fs, err := filesystem.NewFileSystem(share.Creator())
if err != nil {
return serializer.Err(serializer.CodePolicyNotAllowed, err.Error(), err)
return serializer.Err(serializer.CodeCreateFSError, "", err)
}
defer fs.Recycle()

Loading…
Cancel
Save