mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
Use progress when printing. #8
This commit is contained in:
+1
-1
@@ -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
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user