handle db prune errors
This commit is contained in:
parent
38f3f09912
commit
5a087d2f84
1 changed files with 5 additions and 1 deletions
6
main.go
6
main.go
|
@ -263,7 +263,10 @@ func (web *Web) pruneDB() {
|
||||||
for _, storeName := range storeNames {
|
for _, storeName := range storeNames {
|
||||||
log.Println("Pruning:", storeName)
|
log.Println("Pruning:", storeName)
|
||||||
var values []FilterOutput
|
var values []FilterOutput
|
||||||
web.db.Model(&FilterOutput{}).Order("time asc").Find(&values, fmt.Sprintf("name = '%s'", storeName))
|
tx := web.db.Model(&FilterOutput{}).Order("time asc").Find(&values, fmt.Sprintf("name = '%s'", storeName))
|
||||||
|
if tx.Error != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
IDs := make([]uint, 0, len(values))
|
IDs := make([]uint, 0, len(values))
|
||||||
for i := range values {
|
for i := range values {
|
||||||
if i > len(values)-3 {
|
if i > len(values)-3 {
|
||||||
|
@ -382,6 +385,7 @@ func (web *Web) watchCreatePost(c *gin.Context) {
|
||||||
if templateID == -1 { // watch from url template
|
if templateID == -1 { // watch from url template
|
||||||
url := c.PostForm("url")
|
url := c.PostForm("url")
|
||||||
if len(url) == 0 {
|
if len(url) == 0 {
|
||||||
|
|
||||||
c.AbortWithError(http.StatusBadRequest, err)
|
c.AbortWithError(http.StatusBadRequest, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue