switched from path to filepath for files

This commit is contained in:
knoxfighter 2019-03-22 00:49:43 +01:00
parent 27a5f62560
commit dbcaba7231
4 changed files with 7 additions and 8 deletions

View File

@ -63,7 +63,7 @@ func DLSave(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r) vars := mux.Vars(r)
save := vars["save"] save := vars["save"]
saveName := path.Join(config.FactorioSavesDir, save) saveName := filepath.Join(config.FactorioSavesDir, save)
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", save)) w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", save))
log.Printf("%s downloading: %s", r.Host, saveName) log.Printf("%s downloading: %s", r.Host, saveName)

View File

@ -9,7 +9,6 @@ import (
"lockfile" "lockfile"
"log" "log"
"os" "os"
"path"
"path/filepath" "path/filepath"
"strings" "strings"
) )
@ -134,7 +133,7 @@ func (modInfoList *ModInfoList) deleteMod(modName string) error {
//search for mod, that should be deleted //search for mod, that should be deleted
for _, mod := range modInfoList.Mods { for _, mod := range modInfoList.Mods {
if mod.Name == modName { if mod.Name == modName {
filePath := path.Join(modInfoList.Destination, mod.FileName) filePath := filepath.Join(modInfoList.Destination, mod.FileName)
fileLock.LockW(filePath) fileLock.LockW(filePath)
//delete mod //delete mod
@ -195,7 +194,7 @@ func (modInfoList *ModInfoList) createMod(modName string, fileName string, modFi
var err error var err error
//save uploaded file //save uploaded file
filePath := path.Join(modInfoList.Destination, fileName) filePath := filepath.Join(modInfoList.Destination, fileName)
newFile, err := os.Create(filePath) newFile, err := os.Create(filePath)
if err != nil { if err != nil {
log.Printf("error on creating new file - %s: %s", fileName, err) log.Printf("error on creating new file - %s: %s", fileName, err)

View File

@ -276,7 +276,7 @@ func modStartUp() {
} }
newJson, _ := json.Marshal(modSimpleList) newJson, _ := json.Marshal(modSimpleList)
err = ioutil.WriteFile(modSimpleList.Destination+"/mod-list.json", newJson, 0664) err = ioutil.WriteFile(filepath.Join(modSimpleList.Destination,"mod-list.json"), newJson, 0664)
if err != nil { if err != nil {
log.Printf("error when writing new mod-list: %s", err) log.Printf("error when writing new mod-list: %s", err)
return err return err

View File

@ -4,7 +4,7 @@ import (
"errors" "errors"
"log" "log"
"os" "os"
"path" "path/filepath"
"sync" "sync"
"time" "time"
) )
@ -30,7 +30,7 @@ func NewLock() FileLock {
} }
func makeAbsolutePath(target string) string { func makeAbsolutePath(target string) string {
if path.IsAbs(target) { if filepath.IsAbs(target) {
return target return target
} }
@ -40,7 +40,7 @@ func makeAbsolutePath(target string) string {
return "" return ""
} }
return path.Join(wd, target) return filepath.Join(wd, target)
} }
func (fl *FileLock) Lock(filePath string) error { func (fl *FileLock) Lock(filePath string) error {