diff --git a/document/document.go b/document/document.go index fcbd64b..0fa4b86 100644 --- a/document/document.go +++ b/document/document.go @@ -175,6 +175,9 @@ func (d *Document) SaveToFile(path string) (f *os.File, err error) { func DeleteDocuments(docs []*Document) error { for _, d := range docs { + if d == nil { + continue + } if err := d.DeleteFile(); err != nil { return err } diff --git a/quicksort.go b/quicksort.go index f1f2964..70fade7 100644 --- a/quicksort.go +++ b/quicksort.go @@ -50,3 +50,13 @@ func partition(que QuickSortable, low, high int, dir QSortDirection) int { que.Swap(i+1, high) return i + 1 } + +func BubbleSort(arr []int64) { + for i := 0; i < len(arr)-1; i++ { + for j := i; j < len(arr); j++ { + if arr[i] > arr[j] { + arr[i], arr[j] = arr[j], arr[i] + } + } + } +} diff --git a/server.go b/server.go index 27ad8ea..1531a6a 100644 --- a/server.go +++ b/server.go @@ -4,7 +4,6 @@ import ( "database/sql" "fmt" "net/http" - "time" "git.to-net.rs/marko.tikvic/gologger" "github.com/gorilla/mux" @@ -38,7 +37,7 @@ func NewODBCServer(dsn, port, logDir string) (s *Server, err error) { s.DBs["default"] = s.DB s.dsn = make(map[string]string) - s.DBs["default"] = s.DB + s.dsn["default"] = dsn return s, nil } @@ -79,18 +78,3 @@ func CommitChanges(tx *sql.Tx, err *error, opt ...error) { tx.Rollback() } } - -func (s *Server) RefreshDatabaseConnections(period time.Duration) { - for { - for k, db := range s.DBs { - if err := db.Ping(); err != nil { - if s.Logger != nil { - s.Logger.PrintAndTrace("failed to ping database (%s): %s", s.dsn[k], err.Error()) - } else { - fmt.Println("failed to ping database (%s): %s", s.dsn[k], err.Error()) - } - } - } - time.Sleep(period) - } -}