mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2025-01-08 04:04:53 +02:00
switched from path to filepath for files
This commit is contained in:
parent
27a5f62560
commit
dbcaba7231
@ -63,7 +63,7 @@ func DLSave(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
vars := mux.Vars(r)
|
||||
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))
|
||||
log.Printf("%s downloading: %s", r.Host, saveName)
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"lockfile"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
@ -134,7 +133,7 @@ func (modInfoList *ModInfoList) deleteMod(modName string) error {
|
||||
//search for mod, that should be deleted
|
||||
for _, mod := range modInfoList.Mods {
|
||||
if mod.Name == modName {
|
||||
filePath := path.Join(modInfoList.Destination, mod.FileName)
|
||||
filePath := filepath.Join(modInfoList.Destination, mod.FileName)
|
||||
|
||||
fileLock.LockW(filePath)
|
||||
//delete mod
|
||||
@ -195,7 +194,7 @@ func (modInfoList *ModInfoList) createMod(modName string, fileName string, modFi
|
||||
var err error
|
||||
|
||||
//save uploaded file
|
||||
filePath := path.Join(modInfoList.Destination, fileName)
|
||||
filePath := filepath.Join(modInfoList.Destination, fileName)
|
||||
newFile, err := os.Create(filePath)
|
||||
if err != nil {
|
||||
log.Printf("error on creating new file - %s: %s", fileName, err)
|
||||
|
@ -276,7 +276,7 @@ func modStartUp() {
|
||||
}
|
||||
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 {
|
||||
log.Printf("error when writing new mod-list: %s", err)
|
||||
return err
|
||||
|
6
src/vendor/lockfile/lockfile.go
vendored
6
src/vendor/lockfile/lockfile.go
vendored
@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
@ -30,7 +30,7 @@ func NewLock() FileLock {
|
||||
}
|
||||
|
||||
func makeAbsolutePath(target string) string {
|
||||
if path.IsAbs(target) {
|
||||
if filepath.IsAbs(target) {
|
||||
return target
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ func makeAbsolutePath(target string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
return path.Join(wd, target)
|
||||
return filepath.Join(wd, target)
|
||||
}
|
||||
|
||||
func (fl *FileLock) Lock(filePath string) error {
|
||||
|
Loading…
Reference in New Issue
Block a user