Fix: uint may overflow / Test: get user storage

This commit is contained in:
HFO4
2019-12-07 15:05:48 +08:00
parent 9386371097
commit f4c414c0f6
11 changed files with 126 additions and 61 deletions

View File

@@ -138,8 +138,7 @@ Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; verti
{Name: "sendfile", Value: `0`, Type: "download"},
{Name: "defaultTheme", Value: `#3f51b5`, Type: "basic"},
{Name: "header", Value: `X-Sendfile`, Type: "download"},
{Name: "themes", Value: `{"#3f51b5":{"palette":{"common":{"black":"#000","white":"#fff"},"background":{"paper":"#fff","default":"#fafafa"},"primary":{"light":"#7986cb","main":"#3f51b5","dark":"#303f9f","contrastText":"#fff"},"secondary":{"light":"#ff4081","main":"#f50057","dark":"#c51162","contrastText":"#fff"},"error":{"light":"#e57373","main":"#f44336","dark":"#d32f2f","contrastText":"#fff"},"text":{"primary":"rgba(0, 0, 0, 0.87)","secondary":"rgba(0, 0, 0, 0.54)","disabled":"rgba(0, 0, 0, 0.38)","hint":"rgba(0, 0, 0, 0.38)"},"explorer":{"filename":"#474849","icon":"#8f8f8f","bgSelected":"#D5DAF0","emptyIcon":"#e8e8e8"}}}}
`, Type: "basic"},
{Name: "themes", Value: `{"#3f51b5":{"palette":{"primary":{"light":"#7986cb","main":"#3f51b5","dark":"#303f9f","contrastText":"#fff"},"secondary":{"light":"#ff4081","main":"#f50057","dark":"#c51162","contrastText":"#fff"},"error":{"light":"#e57373","main":"#f44336","dark":"#d32f2f","contrastText":"#fff"},"explorer":{"filename":"#474849","icon":"#8f8f8f","bgSelected":"#D5DAF0","emptyIcon":"#e8e8e8"}}}}`, Type: "basic"},
{Name: "refererCheck", Value: `true`, Type: "share"},
{Name: "header", Value: `X-Sendfile`, Type: "download"},
{Name: "aria2_tmppath", Value: `/path/to/public/download`, Type: "aria2"},

View File

@@ -1,6 +1,7 @@
package model
import (
"github.com/HFO4/cloudreve/pkg/conf"
"github.com/jinzhu/gorm"
"github.com/stretchr/testify/assert"
"testing"
@@ -8,10 +9,12 @@ import (
func TestMigration(t *testing.T) {
asserts := assert.New(t)
conf.DatabaseConfig.Type = "sqlite3"
DB, _ = gorm.Open("sqlite3", ":memory:")
asserts.NotPanics(func() {
migration()
})
conf.DatabaseConfig.Type = "mysql"
DB = mockDB
}

View File

@@ -65,7 +65,7 @@ func (user *User) DeductionStorage(size uint64) bool {
DB.Model(user).UpdateColumn("storage", gorm.Expr("storage - ?", size))
return true
}
// 如果要减少的容量超出用容量,则设为零
// 如果要减少的容量超出用容量,则设为零
user.Storage = 0
DB.Model(user).UpdateColumn("storage", 0)