Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
menshen
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leap
menshen
Commits
cc2c6004
Verified
Commit
cc2c6004
authored
5 months ago
by
Pea Nut
Browse files
Options
Downloads
Patches
Plain Diff
Check for empty dburi in OpenDatabase
parent
8c93c820
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!56
Add cli to manage invite tokens, fixes #61
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
storage/db.go
+8
-3
8 additions, 3 deletions
storage/db.go
with
8 additions
and
3 deletions
storage/db.go
+
8
−
3
View file @
cc2c6004
package
storage
import
(
"errors"
"fmt"
"strings"
...
...
@@ -10,6 +11,11 @@ import (
)
func
OpenDatabase
(
dburi
string
)
(
*
sqlx
.
DB
,
error
)
{
if
len
(
dburi
)
==
0
{
return
nil
,
errors
.
New
(
"Could not open database (dburi is empty)"
)
}
// https://www.sqlite.org/wal.html
// https://www.sqlite.org/foreignkeys.html
if
!
strings
.
Contains
(
dburi
,
"?"
)
{
...
...
@@ -25,9 +31,8 @@ func OpenDatabase(dburi string) (*sqlx.DB, error) {
db
.
SetMaxOpenConns
(
1
)
_
,
err
=
db
.
Exec
(
`CREATE TABLE IF NOT EXISTS tokens (
key TEXT PRIMARY KEY NOT NULL,
buckets TEXT NOT NULL
)`
)
key TEXT PRIMARY KEY NOT NULL,
buckets TEXT NOT NULL)`
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Error creating tokens table: %w"
,
err
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment