Extend PublishedStorage interface for Acquire-By-Hash

Signed-off-by: André Roth <neolynx@gmail.com>
This commit is contained in:
André Roth
2017-04-17 23:03:43 +02:00
committed by Oliver Sauder
parent bb2db7e500
commit e07912770e
5 changed files with 113 additions and 19 deletions
+30
View File
@@ -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)
}