mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
fix(fs): cannot delete file while user is deleted (fix #1586)
This commit is contained in:
@@ -234,7 +234,7 @@ func DeleteFiles(files []*File, uid uint) error {
|
||||
user.ID = uid
|
||||
var size uint64
|
||||
for _, file := range files {
|
||||
if file.UserID != uid {
|
||||
if uid > 0 && file.UserID != uid {
|
||||
tx.Rollback()
|
||||
return errors.New("user id not consistent")
|
||||
}
|
||||
@@ -253,9 +253,11 @@ func DeleteFiles(files []*File, uid uint) error {
|
||||
size += file.Size
|
||||
}
|
||||
|
||||
if err := user.ChangeStorage(tx, "-", size); err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
if uid > 0 {
|
||||
if err := user.ChangeStorage(tx, "-", size); err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return tx.Commit().Error
|
||||
|
||||
Reference in New Issue
Block a user