diff --git a/server/common/constants.go b/server/common/constants.go index 2430bddda..89d8a89ec 100644 --- a/server/common/constants.go +++ b/server/common/constants.go @@ -22,7 +22,7 @@ var ( DB_PATH = "state/db/" FTS_PATH = "state/search/" LOG_PATH = "state/log/" - TMP_PATH = "cache/tmp/" + TMP_PATH = "cache/" ) func init() { @@ -39,12 +39,12 @@ func init() { TMP_PATH = filepath.Join(rootPath, TMP_PATH) // STEP2: initialise the config - os.MkdirAll(filepath.Join(GetCurrentDir(), CERT_PATH), os.ModePerm) - os.MkdirAll(filepath.Join(GetCurrentDir(), DB_PATH), os.ModePerm) - os.MkdirAll(filepath.Join(GetCurrentDir(), FTS_PATH), os.ModePerm) - os.MkdirAll(filepath.Join(GetCurrentDir(), LOG_PATH), os.ModePerm) - os.RemoveAll(filepath.Join(GetCurrentDir(), TMP_PATH)) - os.MkdirAll(filepath.Join(GetCurrentDir(), TMP_PATH), os.ModePerm) + os.MkdirAll(GetAbsolutePath(CERT_PATH), os.ModePerm) + os.MkdirAll(GetAbsolutePath(DB_PATH), os.ModePerm) + os.MkdirAll(GetAbsolutePath(FTS_PATH), os.ModePerm) + os.MkdirAll(GetAbsolutePath(LOG_PATH), os.ModePerm) + os.RemoveAll(GetAbsolutePath(TMP_PATH)) + os.MkdirAll(GetAbsolutePath(TMP_PATH), os.ModePerm) } var ( diff --git a/server/common/files.go b/server/common/files.go index 10b3f20a9..bbc17fdb5 100644 --- a/server/common/files.go +++ b/server/common/files.go @@ -13,9 +13,6 @@ func GetCurrentDir() string { if MOCK_CURRENT_DIR != "" { return MOCK_CURRENT_DIR } - if os.Getenv("WORK_DIR") != "" { - return os.Getenv("WORK_DIR") - } ex, _ := os.Executable() return filepath.Dir(ex) } diff --git a/server/ctrl/export.go b/server/ctrl/export.go index 0f9dee996..1ebd78fe1 100644 --- a/server/ctrl/export.go +++ b/server/ctrl/export.go @@ -3,15 +3,17 @@ package ctrl import ( "bytes" "fmt" - "github.com/gorilla/mux" - . "github.com/mickael-kerjean/filestash/server/common" - "github.com/mickael-kerjean/filestash/server/model" "io" "net/http" "os" "os/exec" "runtime" "strings" + + . "github.com/mickael-kerjean/filestash/server/common" + "github.com/mickael-kerjean/filestash/server/model" + + "github.com/gorilla/mux" ) //go:generate sh -c "go run ../generator/emacs-el.go > export_generated.go && go fmt export_generated.go" @@ -37,7 +39,7 @@ func FileExport(ctx *App, res http.ResponseWriter, req *http.Request) { return } - var tmpPath string = GetAbsolutePath(TMP_PATH) + "/export_" + QuickString(10) + var tmpPath string = GetAbsolutePath(TMP_PATH, "/export_"+QuickString(10)) var cmd *exec.Cmd var emacsPath string var outPath string diff --git a/server/plugin/plg_backend_git/index.go b/server/plugin/plg_backend_git/index.go index 463435dcf..1a3150549 100644 --- a/server/plugin/plg_backend_git/index.go +++ b/server/plugin/plg_backend_git/index.go @@ -89,8 +89,8 @@ func (git Git) Init(params map[string]string, app *App) (IBackend, error) { } hash := GenerateID(app) - p.basePath = filepath.Join( - GetAbsolutePath(TMP_PATH), + p.basePath = GetAbsolutePath( + TMP_PATH, "git_"+hash, ) + "/"