fix(sites): remove stale domain links on sync (#110)
Some checks are pending
CI / build (push) Waiting to run
deploy / deploy (push) Waiting to run
test / test (push) Waiting to run

This commit is contained in:
RissRIce 2026-08-09 22:56:39 -06:00 committed by GitHub
parent b48608c4e9
commit bf777a1475
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 41 additions and 0 deletions

View file

@ -100,6 +100,22 @@ func (m *Manager) Sync() error {
if err != nil {
return err
}
wanted := make(map[string]struct{}, len(all))
for _, dm := range all {
wanted[dm.Domain] = struct{}{}
}
entries, err := os.ReadDir(m.domDir)
if err != nil {
return err
}
for _, entry := range entries {
if _, ok := wanted[entry.Name()]; ok {
continue
}
if err := os.RemoveAll(filepath.Join(m.domDir, entry.Name())); err != nil {
return err
}
}
for _, dm := range all {
if err := m.link(dm.Domain, dm.Username); err != nil {
return err