mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-09 06:04:12 +00:00
Use progress for printing. #8
This commit is contained in:
+1
-1
@@ -25,7 +25,7 @@ func aptlyPublishDrop(cmd *commander.Command, args []string) error {
|
||||
return fmt.Errorf("unable to remove: %s", err)
|
||||
}
|
||||
|
||||
fmt.Printf("\nPublished repositroy has been removed successfully.\n")
|
||||
context.Progress().Printf("\nPublished repositroy has been removed successfully.\n")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
+7
-9
@@ -488,34 +488,32 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorage
|
||||
// RemoveFiles removes files that were created by Publish
|
||||
//
|
||||
// It can remove prefix fully, and part of pool (for specific component)
|
||||
func (p *PublishedRepo) RemoveFiles(publishedStorage aptly.PublishedStorage, removePrefix, removePoolComponent bool) error {
|
||||
func (p *PublishedRepo) RemoveFiles(publishedStorage aptly.PublishedStorage, removePrefix, removePoolComponent bool, progress aptly.Progress) error {
|
||||
// I. Easy: remove whole prefix (meta+packages)
|
||||
if removePrefix {
|
||||
err := publishedStorage.RemoveDirs(filepath.Join(p.Prefix, "dists"))
|
||||
err := publishedStorage.RemoveDirs(filepath.Join(p.Prefix, "dists"), progress)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return publishedStorage.RemoveDirs(filepath.Join(p.Prefix, "pool"))
|
||||
return publishedStorage.RemoveDirs(filepath.Join(p.Prefix, "pool"), progress)
|
||||
}
|
||||
|
||||
// II. Medium: remove metadata, it can't be shared as prefix/distribution as unique
|
||||
err := publishedStorage.RemoveDirs(filepath.Join(p.Prefix, "dists", p.Distribution))
|
||||
err := publishedStorage.RemoveDirs(filepath.Join(p.Prefix, "dists", p.Distribution), progress)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// III. Complex: there are no other publishes with the same prefix + component
|
||||
if removePoolComponent {
|
||||
err = publishedStorage.RemoveDirs(filepath.Join(p.Prefix, "pool", p.Component))
|
||||
err = publishedStorage.RemoveDirs(filepath.Join(p.Prefix, "pool", p.Component), progress)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
/// IV: Hard: should have removed published files from the pool + component
|
||||
/// that are unique to this published repo
|
||||
|
||||
/// XXX: TODO
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -686,7 +684,7 @@ func (collection *PublishedRepoCollection) CleanupPrefixComponentFiles(prefix, c
|
||||
referencedFiles := []string{}
|
||||
|
||||
if progress != nil {
|
||||
progress.Printf("Cleaning up prefix %s component %s...\n", prefix, component)
|
||||
progress.Printf("Cleaning up prefix %#v component %#v...\n", prefix, component)
|
||||
}
|
||||
|
||||
for _, r := range collection.list {
|
||||
@@ -763,7 +761,7 @@ func (collection *PublishedRepoCollection) Remove(publishedStorage aptly.Publish
|
||||
}
|
||||
}
|
||||
|
||||
err = repo.RemoveFiles(publishedStorage, removePrefix, removePoolComponent)
|
||||
err = repo.RemoveFiles(publishedStorage, removePrefix, removePoolComponent, progress)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+4
-4
@@ -499,7 +499,7 @@ func (s *PublishedRepoRemoveSuite) TearDownTest(c *C) {
|
||||
}
|
||||
|
||||
func (s *PublishedRepoRemoveSuite) TestRemoveFilesOnlyDist(c *C) {
|
||||
s.repo1.RemoveFiles(s.publishedStorage, false, false)
|
||||
s.repo1.RemoveFiles(s.publishedStorage, false, false, nil)
|
||||
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/anaconda"), Not(PathExists))
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/meduza"), PathExists)
|
||||
@@ -511,7 +511,7 @@ func (s *PublishedRepoRemoveSuite) TestRemoveFilesOnlyDist(c *C) {
|
||||
}
|
||||
|
||||
func (s *PublishedRepoRemoveSuite) TestRemoveFilesWithPool(c *C) {
|
||||
s.repo1.RemoveFiles(s.publishedStorage, false, true)
|
||||
s.repo1.RemoveFiles(s.publishedStorage, false, true, nil)
|
||||
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/anaconda"), Not(PathExists))
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/meduza"), PathExists)
|
||||
@@ -523,7 +523,7 @@ func (s *PublishedRepoRemoveSuite) TestRemoveFilesWithPool(c *C) {
|
||||
}
|
||||
|
||||
func (s *PublishedRepoRemoveSuite) TestRemoveFilesWithPrefix(c *C) {
|
||||
s.repo1.RemoveFiles(s.publishedStorage, true, true)
|
||||
s.repo1.RemoveFiles(s.publishedStorage, true, true, nil)
|
||||
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/anaconda"), Not(PathExists))
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/meduza"), Not(PathExists))
|
||||
@@ -535,7 +535,7 @@ func (s *PublishedRepoRemoveSuite) TestRemoveFilesWithPrefix(c *C) {
|
||||
}
|
||||
|
||||
func (s *PublishedRepoRemoveSuite) TestRemoveFilesWithPrefixRoot(c *C) {
|
||||
s.repo2.RemoveFiles(s.publishedStorage, true, true)
|
||||
s.repo2.RemoveFiles(s.publishedStorage, true, true, nil)
|
||||
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/anaconda"), PathExists)
|
||||
c.Check(filepath.Join(s.publishedStorage.PublicPath(), "ppa/dists/meduza"), PathExists)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
Removing ${HOME}/.aptly/public/dists/sq1...
|
||||
Cleaning up prefix "." component "main"...
|
||||
|
||||
Published repositroy has been removed successfully.
|
||||
|
||||
Reference in New Issue
Block a user