Default working directory when $HOME is not present (#1296)
This commit is contained in:
Родитель
e687255929
Коммит
9938eee80d
|
@ -1,6 +1,7 @@
|
|||
## 2.1.3 (Unreleased)
|
||||
**Bug Fixes**
|
||||
- Invalidate attribute cache entry on `PathAlreadyExists` error in create directory operation.
|
||||
- When `$HOME` environment variable is not present, use the current directory.
|
||||
|
||||
## 2.1.2 (2023-11-17)
|
||||
**Bug Fixes**
|
||||
|
|
|
@ -305,3 +305,13 @@ func GetIdLength(id string) int64 {
|
|||
existingBlockId, _ := base64.StdEncoding.DecodeString(id)
|
||||
return int64(len(existingBlockId))
|
||||
}
|
||||
|
||||
func init() {
|
||||
val, present := os.LookupEnv("HOME")
|
||||
if !present {
|
||||
val = "./"
|
||||
}
|
||||
DefaultWorkDir = filepath.Join(val, ".blobfuse2")
|
||||
DefaultLogFilePath = filepath.Join(DefaultWorkDir, "blobfuse2.log")
|
||||
StatsConfigFilePath = filepath.Join(DefaultWorkDir, "stats_monitor.cfg")
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -95,3 +97,11 @@ func (suite *typesTestSuite) TestFindBlocksToModify() {
|
|||
suite.assert.Equal(largerThanFile, true)
|
||||
suite.assert.Equal(appendOnly, true)
|
||||
}
|
||||
|
||||
func (suite *typesTestSuite) TestDefaultWorkDir() {
|
||||
val, err := os.UserHomeDir()
|
||||
suite.assert.Nil(err)
|
||||
suite.assert.Equal(DefaultWorkDir, filepath.Join(val, ".blobfuse2"))
|
||||
suite.assert.Equal(DefaultLogFilePath, filepath.Join(val, ".blobfuse2/blobfuse2.log"))
|
||||
suite.assert.Equal(StatsConfigFilePath, filepath.Join(val, ".blobfuse2/stats_monitor.cfg"))
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче