From 77a8e7441713ff3bc07916ec81e07031b07adf73 Mon Sep 17 00:00:00 2001 From: ayyghost Date: Thu, 21 Dec 2023 15:57:34 +0000 Subject: [PATCH] ensure linked directory is present --- .gitignore | 1 + updater.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 01a3850..db7f36b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ config.json +minisign.pub updater diff --git a/updater.go b/updater.go index 5e4f582..84a17a5 100644 --- a/updater.go +++ b/updater.go @@ -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 @@ -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)