diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-17 08:45:18 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-17 08:45:18 +0300 |
| commit | eb89e32c6675d4ed50f66580346e5ea8f3d7b5b2 (patch) | |
| tree | 916d5299642622d3344778222e88db16aeace1ae /internal/cli/migrate_kdbx.go | |
| parent | 9e2bf4af8b7b3b4ca2980aa6285482e7db0cd151 (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'internal/cli/migrate_kdbx.go')
| -rw-r--r-- | internal/cli/migrate_kdbx.go | 7 |
1 files changed, 4 insertions, 3 deletions
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) } |
