From d20330186b2ae88c24e834e550e1cdcb631065cb Mon Sep 17 00:00:00 2001 From: George Brighton Date: Sun, 13 Jan 2019 19:29:40 +0000 Subject: [PATCH] Manually check PMS directory exists This is due to a bug in kingpin: https://github.com/alecthomas/kingpin/issues/261 --- backup/backup.go | 8 ++++++++ main.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/backup/backup.go b/backup/backup.go index fc46ede..c62cca1 100644 --- a/backup/backup.go +++ b/backup/backup.go @@ -98,6 +98,14 @@ func findGzCommand() string { // Run stops Plex, performs the backup, then starts Plex again. // It should ideally be run soon after the server maintenance period. func (o *Opts) Run(svc *s3.S3) error { + fi, err := os.Stat(o.Directory) + if err != nil { + return err + } + if !fi.IsDir() { + return fmt.Errorf("%v is not a directory", o.Directory) + } + oldest, err := oldestObject(svc, o.Bucket, o.Prefix) if err != nil { return fmt.Errorf("failed to retrieve oldest backup: %v", err) diff --git a/main.go b/main.go index 06bfbcd..c2a055e 100644 --- a/main.go +++ b/main.go @@ -30,7 +30,7 @@ var ( String() directory = kingpin.Flag("directory", "Location of the 'Plex Media Server' directory to back up."). Default("/var/lib/plexmediaserver/Library/Application Support/Plex Media Server"). - ExistingDir() + String() ) func main() {