MCPcopy Index your code
hub / github.com/aptly-dev/aptly / CleanupAfterMultiDistToggle

Method CleanupAfterMultiDistToggle

deb/publish.go:1625–1654  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
1625func (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
1657func (collection *PublishedRepoCollection) CleanupPrefixComponentFiles(publishedStorageProvider aptly.PublishedStorageProvider,

Callers 2

apiPublishUpdateSwitchFunction · 0.80
apiPublishUpdateFunction · 0.80

Calls 3

GetPublishedStorageMethod · 0.65
RemoveDirsMethod · 0.65

Tested by

no test coverage detected