Skip to content

Commit

Permalink
ensure linked directory is present
Browse files Browse the repository at this point in the history
  • Loading branch information
ayyghost committed Dec 21, 2023
1 parent bc3ed3b commit 77a8e74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
config.json
minisign.pub
updater
8 changes: 8 additions & 0 deletions updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func getReleaseSymlink(deployDir, targetName string) string {

func getLastReleaseID(deployDir, targetName string) (string, error) {
lastReleaseSymlink := getReleaseSymlink(deployDir, targetName)
// make sure it's a symlink
fi, err := os.Lstat(lastReleaseSymlink)
if err != nil {
return "", err
Expand All @@ -129,6 +130,13 @@ func getLastReleaseID(deployDir, targetName string) (string, error) {
if err != nil {
return "", err
}
// don't want to continue if the linked release directory isn't actually there
_, err = os.Stat(lastReleaseDir)
if err != nil {
return "", err
}

// get ID from directory name
split := strings.Split(filepath.Base(lastReleaseDir), "-")
if len(split) != 2 {
return "", fmt.Errorf("invalid last release directory name: %s", lastReleaseDir)
Expand Down

0 comments on commit 77a8e74

Please sign in to comment.