From eb89e32c6675d4ed50f66580346e5ea8f3d7b5b2 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 17 Apr 2026 08:45:18 +0300 Subject: refactor: deduplicate cli/kdbx_store.go using exported keepass helpers (tasks k4+l4) Remove ~90 lines of duplicated code from kdbx_store.go by delegating to EnsureGroup, UpsertEntryByTitle, SetEntryField, SplitDescriptionPath, SanitizeRelativePath exported from internal/keepass. kdbxStore.Save() now delegates to keepass.AtomicSave, eliminating the double-close risk. migrate_kdbx.go updated to use the exported helpers. Co-Authored-By: Claude Sonnet 4.6 --- internal/cli/migrate_kdbx.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'internal/cli/migrate_kdbx.go') diff --git a/internal/cli/migrate_kdbx.go b/internal/cli/migrate_kdbx.go index f4bb58c..bc98d96 100644 --- a/internal/cli/migrate_kdbx.go +++ b/internal/cli/migrate_kdbx.go @@ -10,6 +10,7 @@ import ( "strings" "time" + "codeberg.org/snonux/foostore/internal/keepass" "codeberg.org/snonux/foostore/internal/store" ) @@ -106,7 +107,7 @@ func (c *CLI) cmdMigrateKDBX(ctx context.Context, argv []string) int { } func (c *CLI) migrateOneEntry(ctx context.Context, idx *store.Index, opts migrateKDBXOptions, kdbx KDBXStore, stats *migrateKDBXStats) error { - safePath, err := sanitizeRelativePath(idx.Description) + safePath, err := keepass.SanitizeRelativePath(idx.Description) if err != nil { return fmt.Errorf("entry %q: %w", idx.Description, err) } @@ -117,7 +118,7 @@ func (c *CLI) migrateOneEntry(ctx context.Context, idx *store.Index, opts migrat } if idx.IsBinary() { - groupPath, title, err := splitDescriptionPath(safePath) + groupPath, title, err := keepass.SplitDescriptionPath(safePath) if err != nil { return fmt.Errorf("mapping binary entry %q: %w", idx.Description, err) } @@ -137,7 +138,7 @@ func (c *CLI) migrateOneEntry(ctx context.Context, idx *store.Index, opts migrat return nil } - groupPath, title, err := splitDescriptionPath(safePath) + groupPath, title, err := keepass.SplitDescriptionPath(safePath) if err != nil { return fmt.Errorf("mapping text entry %q: %w", idx.Description, err) } -- cgit v1.2.3