mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-20 00:07:58 +08:00
replication to create time date directory
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||
"google.golang.org/grpc"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||
@@ -40,7 +41,17 @@ func (r *Replicator) Replicate(ctx context.Context, key string, message *filer_p
|
||||
glog.V(4).Infof("skipping %v outside of %v", key, r.source.Dir)
|
||||
return nil
|
||||
}
|
||||
newKey := util.Join(r.sink.GetSinkToDirectory(), key[len(r.source.Dir):])
|
||||
var dateKey string
|
||||
if r.sink.GetName() == "backup" {
|
||||
var crTime int64
|
||||
if message.NewEntry != nil {
|
||||
crTime = message.NewEntry.Attributes.Crtime
|
||||
} else if message.OldEntry != nil {
|
||||
crTime = message.OldEntry.Attributes.Crtime
|
||||
}
|
||||
dateKey = time.Unix(crTime, 0).Format("2006-01-02")
|
||||
}
|
||||
newKey := util.Join(r.sink.GetSinkToDirectory(), dateKey, key[len(r.source.Dir):])
|
||||
glog.V(3).Infof("replicate %s => %s", key, newKey)
|
||||
key = newKey
|
||||
if message.OldEntry != nil && message.NewEntry == nil {
|
||||
|
Reference in New Issue
Block a user