diff --git a/internal/api/account.go b/internal/api/account.go index a2f1e1317..0e2086eb7 100644 --- a/internal/api/account.go +++ b/internal/api/account.go @@ -2,7 +2,6 @@ package api import ( "net/http" - "os" "strconv" "github.com/gin-gonic/gin" @@ -147,12 +146,10 @@ func ShareWithAccount(router *gin.RouterGroup, conf *config.Config) { } for _, file := range files { - srcFileName := conf.OriginalsPath() + string(os.PathSeparator) + file.FileName dstFileName := dst + "/" + file.ShareFileName() - if err := w.Upload(srcFileName, dstFileName); err != nil { - log.Errorf("upload failed: %s", err.Error()) - } + fileShare := entity.NewFileShare(file.ID, m.ID, dstFileName) + fileShare.FirstOrCreate(conf.Db()) } c.JSON(http.StatusOK, files) diff --git a/internal/entity/file_share.go b/internal/entity/file_share.go index 66605b0ed..6e685ba84 100644 --- a/internal/entity/file_share.go +++ b/internal/entity/file_share.go @@ -34,6 +34,8 @@ func NewFileShare(fileID, accountID uint, remoteName string) *FileShare { FileID: fileID, AccountID: accountID, RemoteName: remoteName, + Status: "new", + Error: "", } return result