weed mount can work well
TODO: somehow filer url is returning empty content
This commit is contained in:
@@ -26,7 +26,7 @@ func (filer *EmbeddedStore) AddDirectoryLink(directory *filer2.Entry, delta int3
|
||||
return nil
|
||||
}
|
||||
|
||||
func (filer *EmbeddedStore) SetFileChunks(fullpath filer2.FullPath, fileChunks []*filer_pb.FileChunk) (err error) {
|
||||
func (filer *EmbeddedStore) UpdateEntry(entry *filer2.Entry) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,21 @@ func CompactFileChunks(chunks []*filer_pb.FileChunk) (compacted, garbage []*file
|
||||
return
|
||||
}
|
||||
|
||||
func FindUnusedFileChunks(oldChunks, newChunks []*filer_pb.FileChunk) (unused []*filer_pb.FileChunk) {
|
||||
|
||||
fileIds := make(map[string]bool)
|
||||
for _, interval := range newChunks {
|
||||
fileIds[interval.FileId] = true
|
||||
}
|
||||
for _, chunk := range oldChunks {
|
||||
if found := fileIds[chunk.FileId]; !found {
|
||||
unused = append(unused, chunk)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func logPrintf(name string, visibles []*visibleInterval) {
|
||||
|
||||
// return
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
"os"
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
)
|
||||
|
||||
@@ -113,8 +112,8 @@ func (f *Filer) CreateEntry(entry *Entry) (error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *Filer) SetFileChunks(p FullPath, chunks []*filer_pb.FileChunk) (err error) {
|
||||
return f.store.SetFileChunks(p, chunks)
|
||||
func (f *Filer) UpdateEntry(entry *Entry) (err error) {
|
||||
return f.store.UpdateEntry(entry)
|
||||
}
|
||||
|
||||
func (f *Filer) FindEntry(p FullPath) (found bool, entry *Entry, err error) {
|
||||
|
||||
@@ -69,7 +69,7 @@ var ErrNotFound = errors.New("filer: no entry is found in filer store")
|
||||
|
||||
type FilerStore interface {
|
||||
InsertEntry(*Entry) (error)
|
||||
SetFileChunks(FullPath, []*filer_pb.FileChunk) (err error)
|
||||
UpdateEntry(*Entry) (err error)
|
||||
FindEntry(FullPath) (found bool, entry *Entry, err error)
|
||||
DeleteEntry(FullPath) (fileEntry *Entry, err error)
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"strings"
|
||||
"fmt"
|
||||
"time"
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||
)
|
||||
|
||||
type MemDbStore struct {
|
||||
@@ -29,16 +28,16 @@ func NewMemDbStore() (filer *MemDbStore) {
|
||||
|
||||
func (filer *MemDbStore) InsertEntry(entry *filer2.Entry) (err error) {
|
||||
// println("inserting", entry.FullPath)
|
||||
entry.Crtime = time.Now()
|
||||
filer.tree.ReplaceOrInsert(Entry{entry})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (filer *MemDbStore) SetFileChunks(fullpath filer2.FullPath, fileChunks []*filer_pb.FileChunk) (err error) {
|
||||
found, entry, err := filer.FindEntry(fullpath)
|
||||
func (filer *MemDbStore) UpdateEntry(entry *filer2.Entry) (err error) {
|
||||
found, entry, err := filer.FindEntry(entry.FullPath)
|
||||
if !found {
|
||||
return fmt.Errorf("No such file: %s", fullpath)
|
||||
return fmt.Errorf("No such file: %s", entry.FullPath)
|
||||
}
|
||||
entry.Chunks = fileChunks
|
||||
entry.Mtime = time.Now()
|
||||
filer.tree.ReplaceOrInsert(Entry{entry})
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user