Skip to content

Commit

Permalink
Manually check PMS directory exists
Browse files Browse the repository at this point in the history
This is due to a bug in kingpin: alecthomas/kingpin#261
  • Loading branch information
gebn committed Jan 13, 2019
1 parent 68b73f1 commit d203301
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit d203301

Please sign in to comment.