mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-04-19 19:28:22 +00:00
fix PublishedStorage's ReadLink to return a relative path
previously it'd return an absolute path which makes the path absolutely useless as all other functions of PublishedStorage need relative input and will prepend them with the rootPath, so getting an absolute ReadLink and then trying to remove that'd would ultimately try to remove the absolute path `$root/AbsoluteRoot/LinkTarget` instead of `$root/LinkTarget` add a unit test to actually verify readlink
This commit is contained in:
@@ -267,7 +267,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)
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user