Skip to content

Commit

Permalink
Moved db files to metadata dir
Browse files Browse the repository at this point in the history
  • Loading branch information
akclace committed Dec 5, 2024
1 parent 454ec73 commit 307902c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
dist/
.vscode
/clace
clace.db*
clace_app.db*
clace_fs.db*
metadata/
clace.toml
*.swp
.sw*
Expand Down
5 changes: 5 additions & 0 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ type Server struct {

// NewServer creates a new instance of the Clace Server
func NewServer(config *types.ServerConfig) (*Server, error) {
metadataDir := os.ExpandEnv("$CL_HOME/metadata")
if err := os.MkdirAll(metadataDir, 0700); err != nil {
return nil, fmt.Errorf("error creating metadata directory %s : %w", metadataDir, err)
}

l := types.NewLogger(&config.Log)
db, err := metadata.NewMetadata(l, config)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/system/clace.default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ access_logging = true

# Metadata Storage Config
[metadata]
db_connection = "sqlite:$CL_HOME/clace.db"
db_connection = "sqlite:$CL_HOME/metadata/clace_metadata.db"
auto_upgrade = true

[system]
Expand All @@ -59,10 +59,10 @@ root_serve_list_apps = "auto" # "auto" means serve list_apps app for defau
# any other value means server for specified domain

[plugin."store.in"]
db_connection = "sqlite:$CL_HOME/clace_app.db"
db_connection = "sqlite:$CL_HOME/metdata/clace_app_store.db"

[plugin."fs.in"]
db_connection = "sqlite:$CL_HOME/clace_fs.db"
db_connection = "sqlite:$CL_HOME/metadata/clace_fs.db"

[app_config]
# app config can be set at the app level using a metadata config update. For example:
Expand Down
2 changes: 1 addition & 1 deletion internal/system/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestServerConfig(t *testing.T) {
testutil.AssertEqualsInt(t, "max size MB", 50, c.Log.MaxSizeMB)

// Metadata related settings
testutil.AssertEqualsString(t, "db connection", "sqlite:$CL_HOME/clace.db", c.Metadata.DBConnection)
testutil.AssertEqualsString(t, "db connection", "sqlite:$CL_HOME/metadata/clace_metadata.db", c.Metadata.DBConnection)
testutil.AssertEqualsBool(t, "auto upgrade", true, c.Metadata.AutoUpgrade)

// HTTPS listen related settings
Expand Down

0 comments on commit 307902c

Please sign in to comment.