Back out the table install changes to fix a bug.

This commit is contained in:
Azareal 2019-05-19 16:28:33 +10:00
parent c57f176939
commit 3a000ad177
1 changed files with 7 additions and 66 deletions

View File

@ -10,12 +10,11 @@ import (
"bytes" "bytes"
"database/sql" "database/sql"
"fmt" "fmt"
"os"
"io/ioutil" "io/ioutil"
"os"
"path/filepath" "path/filepath"
"strconv" "strconv"
"strings" "strings"
"sync"
"github.com/Azareal/Gosora/query_gen" "github.com/Azareal/Gosora/query_gen"
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
@ -166,65 +165,7 @@ func (ins *MysqlInstaller) TableDefs() (err error) {
return err return err
} }
// TODO: Can we reduce the amount of boilerplate here? for _, f := range files {
after := []string{"activity_stream_matches"}
c1 := make(chan os.FileInfo)
c2 := make(chan os.FileInfo)
e := make(chan error)
var wg sync.WaitGroup
r := func(c chan os.FileInfo) {
wg.Add(1)
for f := range c {
err := ins.createTable(f)
if err != nil {
e <- err
}
}
wg.Done()
}
go r(c1)
go r(c2)
var a []os.FileInfo
Outer:
for i, f := range files {
if !strings.HasPrefix(f.Name(), "query_") {
continue
}
table := strings.TrimPrefix(f.Name(), "query_")
ext := filepath.Ext(table)
if ext != ".sql" {
continue
}
table = strings.TrimSuffix(table, ext)
for _, tbl := range after {
if tbl == table {
a = append(a, f)
continue Outer
}
}
if i%2 == 0 {
c1 <- f
} else {
c2 <- f
}
}
close(c1)
close(c2)
wg.Wait()
close(e)
var first error
for err := range e {
if first == nil {
first = err
}
}
if first != nil {
return first
}
for _, f := range a {
if !strings.HasPrefix(f.Name(), "query_") { if !strings.HasPrefix(f.Name(), "query_") {
continue continue
} }