Implement local SQLite index database with repositories
- Add SQLite database connection management with proper error handling - Implement schema for files, chunks, blobs, and snapshots tables - Create repository pattern for each database table - Add transaction support with proper rollback handling - Integrate database module with fx dependency injection - Make index path configurable via VAULTIK_INDEX_PATH env var - Add fatal error handling for database integrity issues - Update DESIGN.md to clarify file_chunks vs chunk_files distinction - Remove FinalHash from BlobInfo (blobs are content-addressable) - Add file metadata support (mtime, ctime, mode, uid, gid, symlinks)
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
package globals
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
||||
// these get populated from main() and copied into the Globals object.
|
||||
@@ -21,19 +18,13 @@ type Globals struct {
|
||||
StartTime time.Time
|
||||
}
|
||||
|
||||
func New(lc fx.Lifecycle) (*Globals, error) {
|
||||
func New() (*Globals, error) {
|
||||
n := &Globals{
|
||||
Appname: Appname,
|
||||
Version: Version,
|
||||
Commit: Commit,
|
||||
Appname: Appname,
|
||||
Version: Version,
|
||||
Commit: Commit,
|
||||
StartTime: time.Now(),
|
||||
}
|
||||
|
||||
lc.Append(fx.Hook{
|
||||
OnStart: func(ctx context.Context) error {
|
||||
n.StartTime = time.Now()
|
||||
return nil
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
return n, nil
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package globals
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
|
||||
"go.uber.org/fx"
|
||||
"go.uber.org/fx/fxtest"
|
||||
)
|
||||
@@ -15,22 +15,22 @@ func TestGlobalsNew(t *testing.T) {
|
||||
if g == nil {
|
||||
t.Fatal("Globals instance is nil")
|
||||
}
|
||||
|
||||
|
||||
if g.Appname != "vaultik" {
|
||||
t.Errorf("Expected Appname to be 'vaultik', got '%s'", g.Appname)
|
||||
}
|
||||
|
||||
|
||||
// Version and Commit will be "dev" and "unknown" by default
|
||||
if g.Version == "" {
|
||||
t.Error("Version should not be empty")
|
||||
}
|
||||
|
||||
|
||||
if g.Commit == "" {
|
||||
t.Error("Commit should not be empty")
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
app.RequireStart()
|
||||
app.RequireStop()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user