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/sink | |
| parent | f20ec82a286973a7e3658830637e2e1675729fc5 (diff) | |
| download | seaweedfs-6b54ff991249d2ce5dfbe28ffb503fc770d5db6c.tar.xz seaweedfs-6b54ff991249d2ce5dfbe28ffb503fc770d5db6c.zip | |
replication to create time date directory
Diffstat (limited to 'weed/replication/sink')
| -rw-r--r-- | weed/replication/sink/backupsink/backup_sink.go | 18 | ||||
| -rw-r--r-- | weed/replication/sink/localsink/local_sink.go | 19 |
2 files changed, 24 insertions, 13 deletions
diff --git a/weed/replication/sink/backupsink/backup_sink.go b/weed/replication/sink/backupsink/backup_sink.go new file mode 100644 index 000000000..df0a778d1 --- /dev/null +++ b/weed/replication/sink/backupsink/backup_sink.go @@ -0,0 +1,18 @@ +package backupsink + +import ( + "github.com/chrislusf/seaweedfs/weed/replication/sink" + "github.com/chrislusf/seaweedfs/weed/replication/sink/localsink" +) + +type BackupSink struct { + localsink.LocalSink +} + +func (backupsink *BackupSink) GetName() string { + return "backup" +} + +func init() { + sink.Sinks = append(sink.Sinks, &BackupSink{}) +} diff --git a/weed/replication/sink/localsink/local_sink.go b/weed/replication/sink/localsink/local_sink.go index 5ca562ec8..21c625c3f 100644 --- a/weed/replication/sink/localsink/local_sink.go +++ b/weed/replication/sink/localsink/local_sink.go @@ -12,13 +12,11 @@ import ( "os" "path/filepath" "strings" - "time" ) type LocalSink struct { - dir string - todaysDateFormat string - filerSource *source.FilerSource + Dir string + filerSource *source.FilerSource } func init() { @@ -37,24 +35,19 @@ func (localsink *LocalSink) isMultiPartEntry(key string) bool { return strings.HasSuffix(key, ".part") && strings.Contains(key, "/.uploads/") } -func (localsink *LocalSink) initialize(dir string, todaysDateFormat string) error { - localsink.dir = dir - localsink.todaysDateFormat = todaysDateFormat +func (localsink *LocalSink) initialize(dir string) error { + localsink.Dir = dir return nil } func (localsink *LocalSink) Initialize(configuration util.Configuration, prefix string) error { dir := configuration.GetString(prefix + "directory") - todaysDateFormat := configuration.GetString(prefix + "todays_date_format") glog.V(4).Infof("sink.local.directory: %v", dir) - return localsink.initialize(dir, todaysDateFormat) + return localsink.initialize(dir) } func (localsink *LocalSink) GetSinkToDirectory() string { - if localsink.todaysDateFormat != "" { - return filepath.Join(localsink.dir, time.Now().Format(localsink.todaysDateFormat)) - } - return localsink.dir + return localsink.Dir } func (localsink *LocalSink) DeleteEntry(key string, isDirectory, deleteIncludeChunks bool, signatures []int32) error { |
