feat(delete): real deletes — adapters seeded once into adapter_dir (existing dir is authoritative), sources removed from config.yaml on delete; drop tombstone mechanism for both. Docs: multi-key architecture, gateway_keys as seed

This commit is contained in:
root
2026-08-10 11:52:51 +08:00
parent e2dd4d9727
commit f46b02089c
8 changed files with 184 additions and 67 deletions

View File

@ -94,7 +94,8 @@ func (s *Store) Upsert(src Source) error {
return s.persistLocked()
}
// Remove deletes a runtime source or hides a base YAML source and persists.
// Remove deletes a runtime source from the store and persists. Base YAML
// sources are handled (truly removed from the config file) by the caller.
func (s *Store) Remove(name string) (bool, error) {
s.mu.Lock()
defer s.mu.Unlock()
@ -108,10 +109,7 @@ func (s *Store) Remove(name string) (bool, error) {
kept = append(kept, src)
}
s.data.Sources = kept
if !containsString(s.data.DeletedSources, name) {
s.data.DeletedSources = append(s.data.DeletedSources, name)
}
return removed || containsString(s.data.DeletedSources, name), s.persistLocked()
return removed, s.persistLocked()
}
func (s *Store) DeletedSources() map[string]bool {
@ -124,32 +122,6 @@ func (s *Store) DeletedSources() map[string]bool {
return out
}
func (s *Store) DeleteAdapter(name string) error {
s.mu.Lock()
defer s.mu.Unlock()
if !containsString(s.data.DeletedAdapters, name) {
s.data.DeletedAdapters = append(s.data.DeletedAdapters, name)
}
return s.persistLocked()
}
func (s *Store) RestoreAdapter(name string) error {
s.mu.Lock()
defer s.mu.Unlock()
s.data.DeletedAdapters = removeString(s.data.DeletedAdapters, name)
return s.persistLocked()
}
func (s *Store) DeletedAdapters() map[string]bool {
s.mu.Lock()
defer s.mu.Unlock()
out := map[string]bool{}
for _, name := range s.data.DeletedAdapters {
out[name] = true
}
return out
}
func (s *Store) persistLocked() error {
if s.box != nil {
s.encryptLocked()