CleanupAfterMultiDistToggle cleans up stale pool files left behind when the MultiDist flag is toggled on a published repository. - false→true: Publish() wrote packages into pool/ / / but the old flat pool/ / files were not removed because CleanupPrefixComponentFiles
(publishedStorageProvider aptly.PublishedStorageProvider, published *PublishedRepo, prevMultiDist bool, cleanComponents []string, collectionFactory *CollectionFactory, progress aptly.Progress)
| 1623 | // This is safe because per-distribution pool dirs are exclusive to a single |
| 1624 | // prefix+distribution combination — no other published repo can share them. |
| 1625 | func (collection *PublishedRepoCollection) CleanupAfterMultiDistToggle(publishedStorageProvider aptly.PublishedStorageProvider, |
| 1626 | published *PublishedRepo, prevMultiDist bool, cleanComponents []string, collectionFactory *CollectionFactory, progress aptly.Progress) error { |
| 1627 | if prevMultiDist == published.MultiDist { |
| 1628 | return nil |
| 1629 | } |
| 1630 | |
| 1631 | if !prevMultiDist && published.MultiDist { |
| 1632 | // false→true: use orphan-detection via the existing cleanup, but with |
| 1633 | // MultiDist temporarily set to false so it scans the flat pool layout. |
| 1634 | legacy := *published |
| 1635 | legacy.MultiDist = false |
| 1636 | return collection.CleanupPrefixComponentFiles(publishedStorageProvider, &legacy, cleanComponents, collectionFactory, progress) |
| 1637 | } |
| 1638 | |
| 1639 | // true→false: directly remove the per-distribution pool directories. |
| 1640 | publishedStorage, err := publishedStorageProvider.GetPublishedStorage(published.Storage) |
| 1641 | if err != nil { |
| 1642 | return err |
| 1643 | } |
| 1644 | for _, component := range cleanComponents { |
| 1645 | poolDir := filepath.Join(published.Prefix, "pool", published.Distribution, component) |
| 1646 | if err := publishedStorage.RemoveDirs(poolDir, progress); err != nil { |
| 1647 | return err |
| 1648 | } |
| 1649 | } |
| 1650 | // Remove the distribution-level pool dir if it is now empty. |
| 1651 | distPoolDir := filepath.Join(published.Prefix, "pool", published.Distribution) |
| 1652 | _ = publishedStorage.RemoveDirs(distPoolDir, progress) |
| 1653 | return nil |
| 1654 | } |
| 1655 | |
| 1656 | // CleanupPrefixComponentFiles removes all unreferenced files in published storage under prefix/component pair |
| 1657 | func (collection *PublishedRepoCollection) CleanupPrefixComponentFiles(publishedStorageProvider aptly.PublishedStorageProvider, |
no test coverage detected