diff options
Diffstat (limited to 'weed/replication')
| -rw-r--r-- | weed/replication/sink/azuresink/azure_sink.go | 3 | ||||
| -rw-r--r-- | weed/replication/sink/b2sink/b2_sink.go | 5 | ||||
| -rw-r--r-- | weed/replication/sink/gcssink/gcs_sink.go | 3 | ||||
| -rw-r--r-- | weed/replication/sink/localsink/local_sink.go | 17 | ||||
| -rw-r--r-- | weed/replication/sink/s3sink/s3_sink.go | 3 | ||||
| -rw-r--r-- | weed/replication/source/filer_source.go | 1 |
6 files changed, 18 insertions, 14 deletions
diff --git a/weed/replication/sink/azuresink/azure_sink.go b/weed/replication/sink/azuresink/azure_sink.go index d13a1049b..0ac32b5c1 100644 --- a/weed/replication/sink/azuresink/azure_sink.go +++ b/weed/replication/sink/azuresink/azure_sink.go @@ -129,8 +129,7 @@ func (g *AzureSink) CreateEntry(key string, entry *filer_pb.Entry, signatures [] func (g *AzureSink) UpdateEntry(key string, oldEntry *filer_pb.Entry, newParentPath string, newEntry *filer_pb.Entry, deleteIncludeChunks bool, signatures []int32) (foundExistingEntry bool, err error) { key = cleanKey(key) - // TODO improve efficiency - return false, nil + return true, g.CreateEntry(key, newEntry, signatures) } func cleanKey(key string) string { diff --git a/weed/replication/sink/b2sink/b2_sink.go b/weed/replication/sink/b2sink/b2_sink.go index 90a0bb2e8..4143c039d 100644 --- a/weed/replication/sink/b2sink/b2_sink.go +++ b/weed/replication/sink/b2sink/b2_sink.go @@ -118,11 +118,8 @@ func (g *B2Sink) CreateEntry(key string, entry *filer_pb.Entry, signatures []int } func (g *B2Sink) UpdateEntry(key string, oldEntry *filer_pb.Entry, newParentPath string, newEntry *filer_pb.Entry, deleteIncludeChunks bool, signatures []int32) (foundExistingEntry bool, err error) { - key = cleanKey(key) - - // TODO improve efficiency - return false, nil + return true, g.CreateEntry(key, newEntry, signatures) } func cleanKey(key string) string { diff --git a/weed/replication/sink/gcssink/gcs_sink.go b/weed/replication/sink/gcssink/gcs_sink.go index 5cf5b7317..6f16595e9 100644 --- a/weed/replication/sink/gcssink/gcs_sink.go +++ b/weed/replication/sink/gcssink/gcs_sink.go @@ -116,6 +116,5 @@ func (g *GcsSink) CreateEntry(key string, entry *filer_pb.Entry, signatures []in } func (g *GcsSink) UpdateEntry(key string, oldEntry *filer_pb.Entry, newParentPath string, newEntry *filer_pb.Entry, deleteIncludeChunks bool, signatures []int32) (foundExistingEntry bool, err error) { - // TODO improve efficiency - return false, nil + return true, g.CreateEntry(key, newEntry, signatures) } diff --git a/weed/replication/sink/localsink/local_sink.go b/weed/replication/sink/localsink/local_sink.go index e40ad8bb6..f3d3862ee 100644 --- a/weed/replication/sink/localsink/local_sink.go +++ b/weed/replication/sink/localsink/local_sink.go @@ -8,7 +8,6 @@ import ( "github.com/chrislusf/seaweedfs/weed/replication/sink" "github.com/chrislusf/seaweedfs/weed/replication/source" "github.com/chrislusf/seaweedfs/weed/util" - "io/ioutil" "os" "path/filepath" "strings" @@ -86,8 +85,18 @@ func (localsink *LocalSink) CreateEntry(key string, entry *filer_pb.Entry, signa } } + if entry.IsDirectory { + return os.Mkdir(key, os.FileMode(entry.Attributes.FileMode)) + } + + dstFile, err := os.OpenFile(key, os.O_RDWR|os.O_CREATE|os.O_TRUNC, os.FileMode(entry.Attributes.FileMode)) + if err != nil { + return err + } + defer dstFile.Close() + writeFunc := func(data []byte) error { - writeErr := ioutil.WriteFile(key, data, 0755) + _, writeErr := dstFile.Write(data) return writeErr } @@ -104,5 +113,7 @@ func (localsink *LocalSink) UpdateEntry(key string, oldEntry *filer_pb.Entry, ne } glog.V(4).Infof("Update Entry key: %s", key) // do delete and create - return false, nil + foundExistingEntry = util.FileExists(key) + err = localsink.CreateEntry(key, newEntry, signatures) + return } diff --git a/weed/replication/sink/s3sink/s3_sink.go b/weed/replication/sink/s3sink/s3_sink.go index 9a36573e3..6fbef31e9 100644 --- a/weed/replication/sink/s3sink/s3_sink.go +++ b/weed/replication/sink/s3sink/s3_sink.go @@ -147,8 +147,7 @@ func (s3sink *S3Sink) CreateEntry(key string, entry *filer_pb.Entry, signatures func (s3sink *S3Sink) UpdateEntry(key string, oldEntry *filer_pb.Entry, newParentPath string, newEntry *filer_pb.Entry, deleteIncludeChunks bool, signatures []int32) (foundExistingEntry bool, err error) { key = cleanKey(key) - // TODO improve efficiency - return false, nil + return true, s3sink.CreateEntry(key, newEntry, signatures) } func cleanKey(key string) string { diff --git a/weed/replication/source/filer_source.go b/weed/replication/source/filer_source.go index e2e3575dc..f94ad99dd 100644 --- a/weed/replication/source/filer_source.go +++ b/weed/replication/source/filer_source.go @@ -58,7 +58,6 @@ func (fs *FilerSource) LookupFileId(part string) (fileUrls []string, err error) err = fs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error { - glog.V(4).Infof("read lookup volume id locations: %v", vid) resp, err := client.LookupVolume(context.Background(), &filer_pb.LookupVolumeRequest{ VolumeIds: []string{vid}, }) |
