mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-15 11:57:59 +00:00
New upstream version 1.3.0
This commit is contained in:
+2
-2
@@ -1,8 +1,8 @@
|
||||
package files
|
||||
|
||||
import (
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
"github.com/aptly-dev/aptly/aptly"
|
||||
"github.com/aptly-dev/aptly/utils"
|
||||
)
|
||||
|
||||
type mockChecksumStorage struct {
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
|
||||
"github.com/smira/go-uuid/uuid"
|
||||
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
"github.com/aptly-dev/aptly/aptly"
|
||||
"github.com/aptly-dev/aptly/utils"
|
||||
)
|
||||
|
||||
// PackagePool is deduplicated storage of package files on filesystem
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"runtime"
|
||||
"syscall"
|
||||
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
"github.com/aptly-dev/aptly/aptly"
|
||||
"github.com/aptly-dev/aptly/utils"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
|
||||
+15
-4
@@ -8,8 +8,8 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
"github.com/aptly-dev/aptly/aptly"
|
||||
"github.com/aptly-dev/aptly/utils"
|
||||
)
|
||||
|
||||
// PublishedStorage abstract file system with public dirs (published repos)
|
||||
@@ -97,12 +97,18 @@ func (storage *PublishedStorage) PutFile(path string, sourceFilename string) err
|
||||
|
||||
// Remove removes single file under public path
|
||||
func (storage *PublishedStorage) Remove(path string) error {
|
||||
if len(path) <= 0 {
|
||||
panic("trying to remove empty path")
|
||||
}
|
||||
filepath := filepath.Join(storage.rootPath, path)
|
||||
return os.Remove(filepath)
|
||||
}
|
||||
|
||||
// RemoveDirs removes directory structure under public path
|
||||
func (storage *PublishedStorage) RemoveDirs(path string, progress aptly.Progress) error {
|
||||
if len(path) <= 0 {
|
||||
panic("trying to remove the root directory")
|
||||
}
|
||||
filepath := filepath.Join(storage.rootPath, path)
|
||||
if progress != nil {
|
||||
progress.Printf("Removing %s...\n", filepath)
|
||||
@@ -267,7 +273,12 @@ func (storage *PublishedStorage) FileExists(path string) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// ReadLink returns the symbolic link pointed to by path
|
||||
// ReadLink returns the symbolic link pointed to by path (relative to storage
|
||||
// root)
|
||||
func (storage *PublishedStorage) ReadLink(path string) (string, error) {
|
||||
return os.Readlink(path)
|
||||
absPath, err := os.Readlink(filepath.Join(storage.rootPath, path))
|
||||
if err != nil {
|
||||
return absPath, err
|
||||
}
|
||||
return filepath.Rel(storage.rootPath, absPath)
|
||||
}
|
||||
|
||||
+22
-2
@@ -6,8 +6,8 @@ import (
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
|
||||
"github.com/smira/aptly/aptly"
|
||||
"github.com/smira/aptly/utils"
|
||||
"github.com/aptly-dev/aptly/aptly"
|
||||
"github.com/aptly-dev/aptly/utils"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
@@ -129,6 +129,10 @@ func (s *PublishedStorageSuite) TestSymLink(c *C) {
|
||||
|
||||
exists, _ := s.storage.FileExists("ppa/dists/squeeze/InRelease")
|
||||
c.Check(exists, Equals, true)
|
||||
|
||||
linkTarget, err := s.storage.ReadLink("ppa/dists/squeeze/InRelease")
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(linkTarget, Equals, "ppa/dists/squeeze/Release")
|
||||
}
|
||||
|
||||
func (s *PublishedStorageSuite) TestHardLink(c *C) {
|
||||
@@ -316,3 +320,19 @@ func (s *PublishedStorageSuite) TestLinkFromPool(c *C) {
|
||||
err = s.storageCopySize.LinkFromPool(filepath.Join("", "pool", "main", "m/mars-invaders"), "mars-invaders_1.03.deb", pool, srcPoolPath, sourceChecksum, false)
|
||||
c.Check(err, IsNil)
|
||||
}
|
||||
|
||||
func (s *PublishedStorageSuite) TestRootRemove(c *C) {
|
||||
// Prevent deletion of the root directory by passing empty subpaths.
|
||||
|
||||
pwd := c.MkDir()
|
||||
|
||||
// Symlink
|
||||
linkedDir := filepath.Join(pwd, "linkedDir")
|
||||
os.Symlink(s.root, linkedDir)
|
||||
linkStorage := NewPublishedStorage(linkedDir, "", "")
|
||||
c.Assert(func() { linkStorage.Remove("") }, PanicMatches, "trying to remove empty path")
|
||||
|
||||
// Actual dir
|
||||
dirStorage := NewPublishedStorage(pwd, "", "")
|
||||
c.Assert(func() { dirStorage.RemoveDirs("", nil) }, PanicMatches, "trying to remove the root directory")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user