mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-04 05:10:40 +00:00
Removing files from package pool.
This commit is contained in:
Vendored
+13
@@ -151,3 +151,16 @@ func (r *Repository) PoolFilepathList(progress *utils.Progress) ([]string, error
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PoolRemove deletes file in package pool
|
||||||
|
func (r *Repository) PoolRemove(path string) (size int64, err error) {
|
||||||
|
path = filepath.Join(r.RootPath, "pool", path)
|
||||||
|
|
||||||
|
info, err := os.Stat(path)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = os.Remove(path)
|
||||||
|
return info.Size(), err
|
||||||
|
}
|
||||||
|
|||||||
Vendored
+22
@@ -160,3 +160,25 @@ func (s *RepositorySuite) TestPoolFilepathList(c *C) {
|
|||||||
c.Check(err, IsNil)
|
c.Check(err, IsNil)
|
||||||
c.Check(list, DeepEquals, []string{"ae/0c/1.deb", "ae/0c/2.deb", "bd/0a/3.deb", "bd/0b/4.deb"})
|
c.Check(list, DeepEquals, []string{"ae/0c/1.deb", "ae/0c/2.deb", "bd/0a/3.deb", "bd/0b/4.deb"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *RepositorySuite) TestPoolRemove(c *C) {
|
||||||
|
os.MkdirAll(filepath.Join(s.repo.RootPath, "pool", "bd", "0b"), 0755)
|
||||||
|
os.MkdirAll(filepath.Join(s.repo.RootPath, "pool", "bd", "0a"), 0755)
|
||||||
|
os.MkdirAll(filepath.Join(s.repo.RootPath, "pool", "ae", "0c"), 0755)
|
||||||
|
|
||||||
|
ioutil.WriteFile(filepath.Join(s.repo.RootPath, "pool", "ae", "0c", "1.deb"), []byte("1"), 0644)
|
||||||
|
ioutil.WriteFile(filepath.Join(s.repo.RootPath, "pool", "ae", "0c", "2.deb"), []byte("22"), 0644)
|
||||||
|
ioutil.WriteFile(filepath.Join(s.repo.RootPath, "pool", "bd", "0a", "3.deb"), []byte("333"), 0644)
|
||||||
|
ioutil.WriteFile(filepath.Join(s.repo.RootPath, "pool", "bd", "0b", "4.deb"), []byte("4444"), 0644)
|
||||||
|
|
||||||
|
size, err := s.repo.PoolRemove("ae/0c/2.deb")
|
||||||
|
c.Check(err, IsNil)
|
||||||
|
c.Check(size, Equals, int64(2))
|
||||||
|
|
||||||
|
_, err = s.repo.PoolRemove("ae/0c/2.deb")
|
||||||
|
c.Check(err, ErrorMatches, ".*no such file or directory")
|
||||||
|
|
||||||
|
list, err := s.repo.PoolFilepathList(nil)
|
||||||
|
c.Check(err, IsNil)
|
||||||
|
c.Check(list, DeepEquals, []string{"ae/0c/1.deb", "bd/0a/3.deb", "bd/0b/4.deb"})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user