mirror of https://github.com/dirtbags/moth.git
Warn if mkpuzzle is not executable
This commit is contained in:
parent
d016555fb4
commit
e6dfebdbfe
|
@ -11,6 +11,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/mail"
|
"net/mail"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -140,17 +141,21 @@ type PuzzleProvider interface {
|
||||||
func NewFsPuzzle(fs afero.Fs) PuzzleProvider {
|
func NewFsPuzzle(fs afero.Fs) PuzzleProvider {
|
||||||
var command string
|
var command string
|
||||||
|
|
||||||
if info, err := fs.Stat("mkpuzzle"); (err == nil) && (info.Mode()&0100 != 0) {
|
if info, err := fs.Stat("mkpuzzle"); !os.IsNotExist(err) {
|
||||||
|
if (info.Mode() & 0100) != 0 {
|
||||||
// Try to get the actual path to the executable
|
// Try to get the actual path to the executable
|
||||||
if pfs, ok := fs.(*RecursiveBasePathFs); ok {
|
if pfs, ok := fs.(*RecursiveBasePathFs); ok {
|
||||||
if command, err = pfs.RealPath(info.Name()); err != nil {
|
if command, err = pfs.RealPath(info.Name()); err != nil {
|
||||||
log.Println("Unable to resolve full path to", info.Name(), pfs)
|
log.Println("WARN: Unable to resolve full path to", info.Name(), pfs)
|
||||||
}
|
}
|
||||||
} else if pfs, ok := fs.(*afero.BasePathFs); ok {
|
} else if pfs, ok := fs.(*afero.BasePathFs); ok {
|
||||||
if command, err = pfs.RealPath(info.Name()); err != nil {
|
if command, err = pfs.RealPath(info.Name()); err != nil {
|
||||||
log.Println("Unable to resolve full path to", info.Name(), pfs)
|
log.Println("WARN: Unable to resolve full path to", info.Name(), pfs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log.Println("WARN: mkpuzzle exists, but isn't executable.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if command != "" {
|
if command != "" {
|
||||||
|
|
Loading…
Reference in New Issue