Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Allow self-defined stage directory #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions FileHandleWriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ func NewFileHandleWriter(handle *FileHandle, newFile bool) (*FileHandleWriter, e
}
w.Close()
}
stageDir := "/var/hdfs-mount" // TODO: make configurable
if ok := os.MkdirAll(stageDir, 0700); ok != nil {
Error.Println("Failed to create stageDir /var/hdfs-mount, Error:", ok)
Error.Println("Failed to create stageDir", stageDir, ", Error:", ok)
return nil, ok
}
var err error
Expand Down
5 changes: 5 additions & 0 deletions FileHandleWriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ package main
import (
"bazil.org/fuse"
"errors"
"flag"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"io"
"os"
"testing"
)

func init() {
flag.StringVar(&stageDir, "stageDir", "/var/hdfs-mount", "set stage dir for test")
}

func TestWriteFile(t *testing.T) {
mockCtrl := gomock.NewController(t)
mockClock := &MockClock{}
Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var Usage = func() {
flag.PrintDefaults()
}

var stageDir string

func main() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
Expand All @@ -37,6 +39,7 @@ func main() {
expandZips := flag.Bool("expandZips", false, "Enables automatic expansion of ZIP archives")
readOnly := flag.Bool("readOnly", false, "Enables mount with readonly")
logLevel := flag.Int("logLevel", 0, "logs to be printed. 0: only fatal/err logs; 1: +warning logs; 2: +info logs")
flag.StringVar(&stageDir, "stageDir", "/var/hdfs-mount", "stage directory for writing file")

flag.Usage = Usage
flag.Parse()
Expand Down