diff options
Diffstat (limited to 'weed/util')
| -rw-r--r-- | weed/util/bounded_tree/bounded_tree_test.go | 5 | ||||
| -rw-r--r-- | weed/util/compression.go | 1 | ||||
| -rw-r--r-- | weed/util/constants.go | 2 | ||||
| -rw-r--r-- | weed/util/file_util.go | 20 | ||||
| -rw-r--r-- | weed/util/log_buffer/log_buffer.go | 13 |
5 files changed, 30 insertions, 11 deletions
diff --git a/weed/util/bounded_tree/bounded_tree_test.go b/weed/util/bounded_tree/bounded_tree_test.go index 2328f0497..0b9c3177a 100644 --- a/weed/util/bounded_tree/bounded_tree_test.go +++ b/weed/util/bounded_tree/bounded_tree_test.go @@ -9,9 +9,7 @@ import ( "github.com/chrislusf/seaweedfs/weed/util" ) - var ( - visitFn = func(path util.FullPath) (childDirectories []string, err error) { fmt.Printf(" visit %v ...\n", path) switch path { @@ -37,14 +35,11 @@ var ( return nil, nil } - printMap = func(m map[string]*Node) { for k := range m { println(" >", k) } } - - ) func TestBoundedTree(t *testing.T) { diff --git a/weed/util/compression.go b/weed/util/compression.go index b526f47c9..4488e019e 100644 --- a/weed/util/compression.go +++ b/weed/util/compression.go @@ -54,6 +54,7 @@ func ungzipData(input []byte) ([]byte, error) { } var decoder, _ = zstd.NewReader(nil) + func unzstdData(input []byte) ([]byte, error) { return decoder.DecodeAll(input, nil) } diff --git a/weed/util/constants.go b/weed/util/constants.go index 3433c550b..20aafc228 100644 --- a/weed/util/constants.go +++ b/weed/util/constants.go @@ -5,7 +5,7 @@ import ( ) var ( - VERSION = fmt.Sprintf("%s %d.%d", sizeLimit, 1, 84) + VERSION = fmt.Sprintf("%s %d.%d", sizeLimit, 1, 85) COMMIT = "" ) diff --git a/weed/util/file_util.go b/weed/util/file_util.go index ff725830b..70135180d 100644 --- a/weed/util/file_util.go +++ b/weed/util/file_util.go @@ -3,6 +3,9 @@ package util import ( "errors" "os" + "os/user" + "path/filepath" + "strings" "time" "github.com/chrislusf/seaweedfs/weed/glog" @@ -63,3 +66,20 @@ func CheckFile(filename string) (exists, canRead, canWrite bool, modTime time.Ti fileSize = fi.Size() return } + +func ResolvePath(path string) string { + + usr, _ := user.Current() + dir := usr.HomeDir + + if path == "~" { + // In case of "~", which won't be caught by the "else if" + path = dir + } else if strings.HasPrefix(path, "~/") { + // Use strings.HasPrefix so we don't match paths like + // "/something/~/something/" + path = filepath.Join(dir, path[2:]) + } + + return path +} diff --git a/weed/util/log_buffer/log_buffer.go b/weed/util/log_buffer/log_buffer.go index b02c45b52..cb9565fb2 100644 --- a/weed/util/log_buffer/log_buffer.go +++ b/weed/util/log_buffer/log_buffer.go @@ -145,12 +145,15 @@ func (m *LogBuffer) loopInterval() { func (m *LogBuffer) copyToFlush() *dataToFlush { - if m.flushFn != nil && m.pos > 0 { + if m.pos > 0 { // fmt.Printf("flush buffer %d pos %d empty space %d\n", len(m.buf), m.pos, len(m.buf)-m.pos) - d := &dataToFlush{ - startTime: m.startTime, - stopTime: m.stopTime, - data: copiedBytes(m.buf[:m.pos]), + var d *dataToFlush + if m.flushFn != nil { + d = &dataToFlush{ + startTime: m.startTime, + stopTime: m.stopTime, + data: copiedBytes(m.buf[:m.pos]), + } } // fmt.Printf("flusing [0,%d) with %d entries\n", m.pos, len(m.idx)) m.buf = m.prevBuffers.SealBuffer(m.startTime, m.stopTime, m.buf, m.pos) |
