From 522684aabbc9e5f6a9a5614dd01c757561c64572 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Tue, 22 Apr 2014 17:19:39 +0400 Subject: [PATCH] Use progress for printing. #8 --- cmd/publish_drop.go | 2 +- deb/publish.go | 16 +++++++--------- deb/publish_test.go | 8 ++++---- system/t06_publish/PublishDrop3Test_gold | 1 + 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/cmd/publish_drop.go b/cmd/publish_drop.go index 8cda9bd7..fd34cbee 100644 --- a/cmd/publish_drop.go +++ b/cmd/publish_drop.go @@ -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 } diff --git a/deb/publish.go b/deb/publish.go index 198dc5db..82974424 100644 --- a/deb/publish.go +++ b/deb/publish.go @@ -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 } diff --git a/deb/publish_test.go b/deb/publish_test.go index 1acdcfea..0e49b20a 100644 --- a/deb/publish_test.go +++ b/deb/publish_test.go @@ -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) diff --git a/system/t06_publish/PublishDrop3Test_gold b/system/t06_publish/PublishDrop3Test_gold index bc282720..bdb54421 100644 --- a/system/t06_publish/PublishDrop3Test_gold +++ b/system/t06_publish/PublishDrop3Test_gold @@ -1,3 +1,4 @@ Removing ${HOME}/.aptly/public/dists/sq1... +Cleaning up prefix "." component "main"... Published repositroy has been removed successfully.