mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-06 22:18:28 +00:00
Extend PublishedStorage interface for Acquire-By-Hash
Signed-off-by: André Roth <neolynx@gmail.com>
This commit is contained in:
committed by
Oliver Sauder
parent
bb2db7e500
commit
e07912770e
@@ -247,3 +247,33 @@ func (storage *PublishedStorage) Filelist(prefix string) ([]string, error) {
|
||||
func (storage *PublishedStorage) RenameFile(oldName, newName string) error {
|
||||
return os.Rename(filepath.Join(storage.rootPath, oldName), filepath.Join(storage.rootPath, newName))
|
||||
}
|
||||
|
||||
// SymLink creates a symbolic link, which can be read with ReadLink
|
||||
func (storage *PublishedStorage) SymLink(src string, dst string) error {
|
||||
return os.Symlink(src, filepath.Join(storage.rootPath, dst))
|
||||
}
|
||||
|
||||
// HardLink creates a hardlink of a file
|
||||
func (storage *PublishedStorage) HardLink(src string, dst string) error {
|
||||
return os.Link(filepath.Join(storage.rootPath, src), filepath.Join(storage.rootPath, dst))
|
||||
}
|
||||
|
||||
// FileExists returns true if path exists
|
||||
func (storage *PublishedStorage) FileExists(path string) bool {
|
||||
list, err := storage.Filelist(filepath.Dir(path))
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
f := filepath.Base(path)
|
||||
for _, i := range list {
|
||||
if i == f {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ReadLink returns the symbolic link pointed to by path
|
||||
func (storage *PublishedStorage) ReadLink(path string) (string, error) {
|
||||
return os.Readlink(path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user