mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-12 03:21:33 +00:00
make code less repetitive and more readable
by using the power of variables!
This commit is contained in:
@@ -191,18 +191,19 @@ func packageIndexByHash(file *indexFile, ext string, hash string, sum string) er
|
||||
}
|
||||
|
||||
// if a previous index file already exists exists, backup symlink
|
||||
if exists, _ = file.parent.publishedStorage.FileExists(filepath.Join(dst, indexfile)); exists {
|
||||
indexPath := filepath.Join(dst, indexfile)
|
||||
oldIndexPath := filepath.Join(dst, indexfile+".old")
|
||||
if exists, _ = file.parent.publishedStorage.FileExists(indexPath); exists {
|
||||
// if exists, remove old symlink
|
||||
if exists, _ = file.parent.publishedStorage.FileExists(filepath.Join(dst, indexfile+".old")); exists {
|
||||
var link string
|
||||
link, err = file.parent.publishedStorage.ReadLink(filepath.Join(dst, indexfile+".old"))
|
||||
if exists, _ = file.parent.publishedStorage.FileExists(oldIndexPath); exists {
|
||||
var linkTarget string
|
||||
linkTarget, err = file.parent.publishedStorage.ReadLink(oldIndexPath)
|
||||
if err != nil {
|
||||
file.parent.publishedStorage.Remove(link)
|
||||
file.parent.publishedStorage.Remove(linkTarget)
|
||||
}
|
||||
file.parent.publishedStorage.Remove(filepath.Join(dst, indexfile+".old"))
|
||||
file.parent.publishedStorage.Remove(oldIndexPath)
|
||||
}
|
||||
file.parent.publishedStorage.RenameFile(filepath.Join(dst, indexfile),
|
||||
filepath.Join(dst, indexfile+".old"))
|
||||
file.parent.publishedStorage.RenameFile(indexPath, oldIndexPath)
|
||||
}
|
||||
|
||||
// create symlink
|
||||
|
||||
Reference in New Issue
Block a user