mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-27 13:57:46 +00:00
Adjust FileExists to differentiate between error and actual file existence
This commit is contained in:
+3
-3
@@ -259,12 +259,12 @@ func (storage *PublishedStorage) HardLink(src string, dst string) error {
|
||||
}
|
||||
|
||||
// FileExists returns true if path exists
|
||||
func (storage *PublishedStorage) FileExists(path string) bool {
|
||||
func (storage *PublishedStorage) FileExists(path string) (bool, error) {
|
||||
if _, err := os.Lstat(filepath.Join(storage.rootPath, path)); os.IsNotExist(err) {
|
||||
return false
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return true
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// ReadLink returns the symbolic link pointed to by path
|
||||
|
||||
@@ -107,13 +107,13 @@ func (s *PublishedStorageSuite) TestFileExists(c *C) {
|
||||
err := s.storage.MkDir("ppa/dists/squeeze/")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
exists := s.storage.FileExists("ppa/dists/squeeze/Release")
|
||||
exists, _ := s.storage.FileExists("ppa/dists/squeeze/Release")
|
||||
c.Check(exists, Equals, false)
|
||||
|
||||
err = s.storage.PutFile("ppa/dists/squeeze/Release", "/dev/null")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
exists = s.storage.FileExists("ppa/dists/squeeze/Release")
|
||||
exists, _ = s.storage.FileExists("ppa/dists/squeeze/Release")
|
||||
c.Check(exists, Equals, true)
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ func (s *PublishedStorageSuite) TestSymLink(c *C) {
|
||||
err = s.storage.SymLink("ppa/dists/squeeze/Release", "ppa/dists/squeeze/InRelease")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
exists := s.storage.FileExists("ppa/dists/squeeze/InRelease")
|
||||
exists, _ := s.storage.FileExists("ppa/dists/squeeze/InRelease")
|
||||
c.Check(exists, Equals, true)
|
||||
}
|
||||
|
||||
@@ -141,11 +141,10 @@ func (s *PublishedStorageSuite) TestHardLink(c *C) {
|
||||
err = s.storage.HardLink("ppa/dists/squeeze/Release", "ppa/dists/squeeze/InRelease")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
exists := s.storage.FileExists("ppa/dists/squeeze/InRelease")
|
||||
exists, _ := s.storage.FileExists("ppa/dists/squeeze/InRelease")
|
||||
c.Check(exists, Equals, true)
|
||||
}
|
||||
|
||||
|
||||
func (s *PublishedStorageSuite) TestRemoveDirs(c *C) {
|
||||
err := s.storage.MkDir("ppa/dists/squeeze/")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
Reference in New Issue
Block a user