diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-01-28 02:17:41 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-01-28 02:17:41 -0800 |
| commit | da08402ba253fe5391f0152905f51f82c51fd527 (patch) | |
| tree | 3f62e21364b01ff9f15768b6c898df99554a5869 | |
| parent | 822f1ade9d3f613e4f400ed0945f52b3bbba3780 (diff) | |
| download | seaweedfs-da08402ba253fe5391f0152905f51f82c51fd527.tar.xz seaweedfs-da08402ba253fe5391f0152905f51f82c51fd527.zip | |
replicate: use creation time for local incremental file sink
related to https://github.com/chrislusf/seaweedfs/pull/1762
| -rw-r--r-- | weed/command/filer_replication.go | 1 | ||||
| -rw-r--r-- | weed/command/scaffold.go | 3 | ||||
| -rw-r--r-- | weed/replication/replicator.go | 8 | ||||
| -rw-r--r-- | weed/replication/sink/localsink/local_incremental_sink.go (renamed from weed/replication/sink/localincrementalsink/local_incremental_sink.go) | 5 |
4 files changed, 7 insertions, 10 deletions
diff --git a/weed/command/filer_replication.go b/weed/command/filer_replication.go index 47ef5d1b6..e8c06b208 100644 --- a/weed/command/filer_replication.go +++ b/weed/command/filer_replication.go @@ -11,7 +11,6 @@ import ( _ "github.com/chrislusf/seaweedfs/weed/replication/sink/b2sink" _ "github.com/chrislusf/seaweedfs/weed/replication/sink/filersink" _ "github.com/chrislusf/seaweedfs/weed/replication/sink/gcssink" - _ "github.com/chrislusf/seaweedfs/weed/replication/sink/localincrementalsink" _ "github.com/chrislusf/seaweedfs/weed/replication/sink/localsink" _ "github.com/chrislusf/seaweedfs/weed/replication/sink/s3sink" "github.com/chrislusf/seaweedfs/weed/replication/sub" diff --git a/weed/command/scaffold.go b/weed/command/scaffold.go index a95c41054..3ac7c021d 100644 --- a/weed/command/scaffold.go +++ b/weed/command/scaffold.go @@ -354,11 +354,10 @@ directory = "/buckets" [sink.local] enabled = false directory = "/data" -todays_date_format = "" # set this to 2006-02-01 for incremental backup [sink.local_incremental] +# all replicated files are under creation time as yyyy-mm-dd directories enabled = false -# all replicated files are under modification time date directory tree directory = "/backup" [sink.filer] diff --git a/weed/replication/replicator.go b/weed/replication/replicator.go index 7688029e6..90e1f7cdd 100644 --- a/weed/replication/replicator.go +++ b/weed/replication/replicator.go @@ -43,13 +43,13 @@ func (r *Replicator) Replicate(ctx context.Context, key string, message *filer_p } var dateKey string if r.sink.GetName() == "local_incremental" { - var mTime int64 + var cTime int64 if message.NewEntry != nil { - mTime = message.NewEntry.Attributes.Mtime + cTime = message.NewEntry.Attributes.Crtime } else if message.OldEntry != nil { - mTime = message.OldEntry.Attributes.Mtime + cTime = message.OldEntry.Attributes.Crtime } - dateKey = time.Unix(mTime, 0).Format("2006-01-02") + dateKey = time.Unix(cTime, 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) diff --git a/weed/replication/sink/localincrementalsink/local_incremental_sink.go b/weed/replication/sink/localsink/local_incremental_sink.go index 97da3a5f7..a1d49e28a 100644 --- a/weed/replication/sink/localincrementalsink/local_incremental_sink.go +++ b/weed/replication/sink/localsink/local_incremental_sink.go @@ -1,12 +1,11 @@ -package localincrementalsink +package localsink import ( "github.com/chrislusf/seaweedfs/weed/replication/sink" - "github.com/chrislusf/seaweedfs/weed/replication/sink/localsink" ) type LocalIncSink struct { - localsink.LocalSink + LocalSink } func (localincsink *LocalIncSink) GetName() string { |
