Pack 3.0.0.Beta2

This commit is contained in:
zicla
2019-05-07 02:21:39 +08:00
parent 5b95c1a2f4
commit 4780ff8698
26 changed files with 220 additions and 187 deletions

View File

@ -332,39 +332,6 @@ func (this *MatterDao) SizeByPuuidAndUserUuid(matterUuid string, userUuid string
return sumSize
}
// compute route size. It will compute upward until root directory
func (this *MatterDao) ComputeRouteSize(matterUuid string, userUuid string) {
//if to root directory, then update to user's info.
if matterUuid == MATTER_ROOT {
size := this.SizeByPuuidAndUserUuid(MATTER_ROOT, userUuid)
db := core.CONTEXT.GetDB().Model(&User{}).Where("uuid = ?", userUuid).Update("total_size", size)
this.PanicError(db.Error)
return
}
matter := this.CheckByUuid(matterUuid)
//only compute dir
if matter.Dir {
//compute the total size.
size := this.SizeByPuuidAndUserUuid(matterUuid, userUuid)
//when changed, we update
if matter.Size != size {
db := core.CONTEXT.GetDB().Model(&Matter{}).Where("uuid = ?", matterUuid).Update("size", size)
this.PanicError(db.Error)
}
}
//update parent recursively.
this.ComputeRouteSize(matter.Puuid, userUuid)
}
//delete a file from db and disk.
func (this *MatterDao) Delete(matter *Matter) {