Skip to content

Commit

Permalink
fix: remove the storage used incr for the outline disk
Browse files Browse the repository at this point in the history
  • Loading branch information
saltbo committed Jul 15, 2021
1 parent 4ec91b0 commit 2c4ae11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/app/dao/matter.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,16 @@ func (ms *Matter) FindUserMatter(uid int64, alias string) (*model.Matter, error)
return m, nil
}

func (ms *Matter) Uploaded(matter *model.Matter) error {
func (ms *Matter) Uploaded(matter *model.Matter, incrUsed bool) error {
fc := func(tx *gorm.DB) error {
if err := tx.First(matter).Update("uploaded_at", time.Now()).Error; err != nil {
return err
}

if !incrUsed {
return nil
}

// update the storage used of the user
expr := gorm.Expr("used+?", matter.Size)
if err := tx.Model(&model.UserStorage{}).Where("uid=?", matter.Uid).Update("used", expr).Error; err != nil {
Expand Down
7 changes: 6 additions & 1 deletion internal/pkg/fakefs/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ func (f *File) UploadDone(uid int64, alias string) (*model.Matter, error) {
return nil, err
}

if err := f.dMatter.Uploaded(m); err != nil {
s, err := f.sStorage.Get(m.Sid)
if err != nil {
return nil, err
}

if err := f.dMatter.Uploaded(m, s.Mode == model.StorageModeNetDisk); err != nil {
return nil, err
}

Expand Down

0 comments on commit 2c4ae11

Please sign in to comment.