diff options
| author | Konstantin Lebedev <lebedev_k@tochka.com> | 2021-01-27 15:01:33 +0500 |
|---|---|---|
| committer | Konstantin Lebedev <lebedev_k@tochka.com> | 2021-01-27 15:01:33 +0500 |
| commit | 6b54ff991249d2ce5dfbe28ffb503fc770d5db6c (patch) | |
| tree | be976960762dd48045a6a17387efd130ea1ba057 /weed/replication/replicator.go | |
| parent | f20ec82a286973a7e3658830637e2e1675729fc5 (diff) | |
| download | seaweedfs-6b54ff991249d2ce5dfbe28ffb503fc770d5db6c.tar.xz seaweedfs-6b54ff991249d2ce5dfbe28ffb503fc770d5db6c.zip | |
replication to create time date directory
Diffstat (limited to 'weed/replication/replicator.go')
| -rw-r--r-- | weed/replication/replicator.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/weed/replication/replicator.go b/weed/replication/replicator.go index c4228434f..81d546c3c 100644 --- a/weed/replication/replicator.go +++ b/weed/replication/replicator.go @@ -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 { |
