Use progress when printing. #8

This commit is contained in:
Andrey Smirnov
2014-04-22 17:19:10 +04:00
parent 9445f3a0fa
commit 8963cd8027
3 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ type PublishedStorage interface {
// CreateFile creates file for writing under public path // CreateFile creates file for writing under public path
CreateFile(path string) (*os.File, error) CreateFile(path string) (*os.File, error)
// RemoveDirs removes directory structure under public path // RemoveDirs removes directory structure under public path
RemoveDirs(path string) error RemoveDirs(path string, progress Progress) error
// Remove removes single file under public path // Remove removes single file under public path
Remove(path string) error Remove(path string) error
// LinkFromPool links package file from pool to dist's pool location // LinkFromPool links package file from pool to dist's pool location
+4 -4
View File
@@ -1,7 +1,6 @@
package files package files
import ( import (
"fmt"
"github.com/smira/aptly/aptly" "github.com/smira/aptly/aptly"
"github.com/smira/aptly/utils" "github.com/smira/aptly/utils"
"os" "os"
@@ -41,14 +40,15 @@ func (storage *PublishedStorage) CreateFile(path string) (*os.File, error) {
// Remove removes single file under public path // Remove removes single file under public path
func (storage *PublishedStorage) Remove(path string) error { func (storage *PublishedStorage) Remove(path string) error {
filepath := filepath.Join(storage.rootPath, path) filepath := filepath.Join(storage.rootPath, path)
fmt.Printf("Removing %s...\n", filepath)
return os.Remove(filepath) return os.Remove(filepath)
} }
// RemoveDirs removes directory structure under public path // RemoveDirs removes directory structure under public path
func (storage *PublishedStorage) RemoveDirs(path string) error { func (storage *PublishedStorage) RemoveDirs(path string, progress aptly.Progress) error {
filepath := filepath.Join(storage.rootPath, path) filepath := filepath.Join(storage.rootPath, path)
fmt.Printf("Removing %s...\n", filepath) if progress != nil {
progress.Printf("Removing %s...\n", filepath)
}
return os.RemoveAll(filepath) return os.RemoveAll(filepath)
} }
+1 -1
View File
@@ -84,7 +84,7 @@ func (s *PublishedStorageSuite) TestRemoveDirs(c *C) {
c.Assert(err, IsNil) c.Assert(err, IsNil)
defer file.Close() defer file.Close()
err = s.storage.RemoveDirs("ppa/dists/") err = s.storage.RemoveDirs("ppa/dists/", nil)
_, err = os.Stat(filepath.Join(s.storage.rootPath, "ppa/dists/squeeze/Release")) _, err = os.Stat(filepath.Join(s.storage.rootPath, "ppa/dists/squeeze/Release"))
c.Assert(err, NotNil) c.Assert(err, NotNil)