mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
pointers are hard
This commit is contained in:
@ -44,24 +44,28 @@ func main() {
|
|||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
log.Printf("--- %s", f)
|
log.Printf("--- %s", f)
|
||||||
|
|
||||||
var found *github.ReleaseAsset
|
var found github.ReleaseAsset
|
||||||
var foundOld *github.ReleaseAsset
|
var exists bool
|
||||||
|
var foundOld bool
|
||||||
for _, ass := range rel.Assets {
|
for _, ass := range rel.Assets {
|
||||||
if ass.GetName() == f {
|
if ass.GetName() == f {
|
||||||
found = &ass
|
exists = true
|
||||||
|
found = ass
|
||||||
}
|
}
|
||||||
if ass.GetName() == f+".old" {
|
if ass.GetName() == f+".old" {
|
||||||
foundOld = &ass
|
foundOld = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if foundOld != nil {
|
|
||||||
|
if foundOld {
|
||||||
log.Fatalf("%s.old was already found. Previous deploy likely failed. Please check and manually delete.", f)
|
log.Fatalf("%s.old was already found. Previous deploy likely failed. Please check and manually delete.", f)
|
||||||
}
|
}
|
||||||
if found != nil {
|
if exists {
|
||||||
n := found.GetName() + ".old"
|
oldN := found.GetName()
|
||||||
|
n := oldN + ".old"
|
||||||
found.Name = &n
|
found.Name = &n
|
||||||
log.Printf("Renaming old asset %s(%d) to .old", found.GetName(), found.GetID())
|
log.Printf("Renaming old asset %s(%d) to %s", oldN, found.GetID(), found.GetName())
|
||||||
_, _, err = c.Repositories.EditReleaseAsset(bg(), owner, repo, found.GetID(), found)
|
_, _, err = c.Repositories.EditReleaseAsset(bg(), owner, repo, found.GetID(), &found)
|
||||||
check(err)
|
check(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +77,7 @@ func main() {
|
|||||||
_, _, err = c.Repositories.UploadReleaseAsset(bg(), owner, repo, rel.GetID(), upOpts, f)
|
_, _, err = c.Repositories.UploadReleaseAsset(bg(), owner, repo, rel.GetID(), upOpts, f)
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
if found != nil {
|
if exists {
|
||||||
log.Println("Deleting old asset")
|
log.Println("Deleting old asset")
|
||||||
_, err = c.Repositories.DeleteReleaseAsset(bg(), owner, repo, found.GetID())
|
_, err = c.Repositories.DeleteReleaseAsset(bg(), owner, repo, found.GetID())
|
||||||
check(err)
|
check(err)
|
||||||
|
Reference in New Issue
Block a user