go fmt
This commit is contained in:
parent
46a0f5a187
commit
e1f5afa788
5
dau.go
5
dau.go
@ -27,14 +27,13 @@ import (
|
||||
// "github.com/skratchdot/open-golang/open"
|
||||
"golang.org/x/image/font/inconsolata"
|
||||
|
||||
"github.com/tardisx/discord-auto-upload/web"
|
||||
"github.com/tardisx/discord-auto-upload/config"
|
||||
"github.com/tardisx/discord-auto-upload/web"
|
||||
)
|
||||
|
||||
var lastCheck = time.Now()
|
||||
var newLastCheck = time.Now()
|
||||
|
||||
|
||||
func main() {
|
||||
|
||||
parseOptions()
|
||||
@ -55,7 +54,7 @@ func main() {
|
||||
log.Fatal("could not watch path", err)
|
||||
}
|
||||
lastCheck = newLastCheck
|
||||
log.Print("sleeping before next check");
|
||||
log.Print("sleeping before next check")
|
||||
time.Sleep(time.Duration(config.Config.Watch) * time.Second)
|
||||
}
|
||||
}
|
||||
|
@ -3,17 +3,16 @@ package web
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/tardisx/discord-auto-upload/assets"
|
||||
"log"
|
||||
"net/http"
|
||||
"github.com/tardisx/discord-auto-upload/assets"
|
||||
// "strings"
|
||||
"regexp"
|
||||
"github.com/tardisx/discord-auto-upload/config"
|
||||
"mime"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"mime"
|
||||
"regexp"
|
||||
"text/template"
|
||||
|
||||
)
|
||||
|
||||
// DAUWebServer - stuff for the web server
|
||||
@ -39,7 +38,7 @@ func getStatic(w http.ResponseWriter, r *http.Request) {
|
||||
sanitized_path := re.ReplaceAll([]byte(path), []byte("_"))
|
||||
|
||||
if string(sanitized_path) == "" {
|
||||
sanitized_path = []byte("index.html");
|
||||
sanitized_path = []byte("index.html")
|
||||
}
|
||||
|
||||
data, err := assets.Asset(string(sanitized_path))
|
||||
@ -48,7 +47,6 @@ func getStatic(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintln(w, err)
|
||||
}
|
||||
|
||||
|
||||
extension := filepath.Ext(string(sanitized_path))
|
||||
|
||||
// is this a HTML file? if so wrap it in the template
|
||||
@ -121,13 +119,13 @@ func getSetDirectory(w http.ResponseWriter, r *http.Request) {
|
||||
response := errorResponse{Success: false, Error: fmt.Sprintf("Path: %s - does not exist", newPath)}
|
||||
js, _ := json.Marshal(response)
|
||||
w.Write(js)
|
||||
return;
|
||||
return
|
||||
} else if !stat.IsDir() {
|
||||
// not a directory
|
||||
response := errorResponse{Success: false, Error: fmt.Sprintf("Path: %s - is not a directory", newPath)}
|
||||
js, _ := json.Marshal(response)
|
||||
w.Write(js)
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
config.Config.Path = newPath
|
||||
|
Loading…
x
Reference in New Issue
Block a user