Skip to content

Commit

Permalink
feature (path): configurable path for generated data
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-kerjean committed Mar 18, 2024
1 parent da5d076 commit 4244c9c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
14 changes: 7 additions & 7 deletions server/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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 (
Expand Down
3 changes: 0 additions & 3 deletions server/common/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
10 changes: 6 additions & 4 deletions server/ctrl/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions server/plugin/plg_backend_git/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) + "/"

Expand Down

0 comments on commit 4244c9c

Please sign in to comment.