mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-06-05 22:53:53 +00:00
fixup! chore: move directory setup from Helm initContainers to Dockerfiles
This commit is contained in:
@@ -285,7 +285,9 @@ metadata:
|
||||
size: "10Gi"
|
||||
accessMode: "ReadWriteOnce"
|
||||
existingClaim: ""
|
||||
walMode: true
|
||||
# WAL mode provides better concurrency but doesn't work on network filesystems (SMB, NFS)
|
||||
# Set to false when using network storage for the metadata volume
|
||||
walMode: false
|
||||
|
||||
# PostgreSQL configuration
|
||||
postgresql:
|
||||
|
||||
+4
-2
@@ -120,7 +120,8 @@ func (a *App) initializeComponents() error {
|
||||
switch a.config.Metadata.Backend {
|
||||
case "sqlite":
|
||||
a.metadata, err = metasqlite.New(metasqlite.Config{
|
||||
Path: a.config.Metadata.Connection,
|
||||
Path: a.config.Metadata.Connection,
|
||||
WALMode: a.config.Metadata.SQLite.WALMode,
|
||||
})
|
||||
case "file":
|
||||
a.metadata, err = metafile.New(metafile.Config{
|
||||
@@ -128,7 +129,8 @@ func (a *App) initializeComponents() error {
|
||||
})
|
||||
default:
|
||||
a.metadata, err = metasqlite.New(metasqlite.Config{
|
||||
Path: "gohoarder.db",
|
||||
Path: "gohoarder.db",
|
||||
WALMode: false, // Default to DELETE mode for compatibility
|
||||
})
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
@@ -27,6 +27,7 @@ type Config struct {
|
||||
Path string // Database file path
|
||||
MaxOpenConns int // Maximum open connections
|
||||
MaxIdleConns int // Maximum idle connections
|
||||
WALMode bool // Enable WAL mode (should be false for network filesystems)
|
||||
}
|
||||
|
||||
const schema = `
|
||||
@@ -134,8 +135,14 @@ func New(cfg Config) (*SQLiteStore, error) {
|
||||
cfg.MaxIdleConns = 5
|
||||
}
|
||||
|
||||
// Open database with WAL mode for better concurrency
|
||||
dsn := fmt.Sprintf("%s?_journal_mode=WAL&_busy_timeout=5000&_synchronous=NORMAL&_cache_size=2000", cfg.Path)
|
||||
// Build DSN with journal mode based on configuration
|
||||
// WAL mode is better for concurrency but doesn't work on network filesystems (SMB, NFS)
|
||||
// Use DELETE mode for network filesystems for compatibility
|
||||
journalMode := "DELETE"
|
||||
if cfg.WALMode {
|
||||
journalMode = "WAL"
|
||||
}
|
||||
dsn := fmt.Sprintf("%s?_journal_mode=%s&_busy_timeout=5000&_synchronous=NORMAL&_cache_size=2000", cfg.Path, journalMode)
|
||||
db, err := sql.Open("sqlite", dsn)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, errors.ErrCodeStorageFailure, "failed to open SQLite database")
|
||||
|
||||
Reference in New Issue
Block a user