fix(docs/storage): resolve FLAW-02, remove unused docDir and update documentation for pure database architecture
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 39s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 39s
This commit is contained in:
1 parent
3480859d8a
commit
0bdeb5f320
7 files changed
+42
-52
No files matched your search
@@ -21,19 +21,15 @@ import (
|
||||
|
||||
type Store struct {
|
||||
db *sql.DB
|
||||
docDir string
|
||||
initMu sync.Mutex
|
||||
}
|
||||
|
||||
func NewStore(dbPath string) (*Store, error) {
|
||||
var docDir string
|
||||
if dbPath != ":memory:" && !strings.HasPrefix(dbPath, "file:") {
|
||||
dir := filepath.Dir(dbPath)
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
return nil, fmt.Errorf("failed to create data directory %s: %w", dir, err)
|
||||
}
|
||||
docDir = filepath.Join(dir, "workspace")
|
||||
_ = os.MkdirAll(docDir, 0755)
|
||||
}
|
||||
|
||||
dsn := dbPath
|
||||
@@ -49,7 +45,7 @@ func NewStore(dbPath string) (*Store, error) {
|
||||
db.SetMaxOpenConns(8)
|
||||
db.SetMaxIdleConns(4)
|
||||
|
||||
store := &Store{db: db, docDir: docDir}
|
||||
store := &Store{db: db}
|
||||
if err := store.migrate(); err != nil {
|
||||
return nil, fmt.Errorf("failed to run migrations: %w", err)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@@ -332,7 +331,6 @@ func TestEnsureDemoAccountsAndLoginLookup(t *testing.T) {
|
||||
func TestFolderManagementAndDeletion(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
dbPath := filepath.Join(tmpDir, "folder_test.db")
|
||||
docDir := filepath.Join(tmpDir, "workspace")
|
||||
|
||||
store, err := NewStore(dbPath)
|
||||
if err != nil {
|
||||
@@ -345,7 +343,7 @@ func TestFolderManagementAndDeletion(t *testing.T) {
|
||||
t.Fatalf("CreateUser failed: %v", err)
|
||||
}
|
||||
|
||||
// 1. Create folders on disk
|
||||
// 1. Create folders
|
||||
f1, err := store.CreateFolder(user.ID, "Projekte/MindSift")
|
||||
if err != nil || f1 != "Projekte/MindSift" {
|
||||
t.Fatalf("CreateFolder failed: %v, f1=%s", err, f1)
|
||||
@@ -401,12 +399,6 @@ func TestFolderManagementAndDeletion(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Fatalf("expected doc2 to be deleted")
|
||||
}
|
||||
|
||||
// Verify disk directory was deleted
|
||||
diskFolder := filepath.Join(docDir, user.ID, "Projekte/MindSift")
|
||||
if _, err := os.Stat(diskFolder); !os.IsNotExist(err) {
|
||||
t.Fatalf("expected directory %s to be deleted on disk", diskFolder)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorkspaceBlockHashtagsAndDetails(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user