diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2021-01-27 00:15:16 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-27 00:15:16 -0800 |
| commit | 2266b5c5286fd4e70d05fc4c5c64cd617809982f (patch) | |
| tree | 470124377fe37747b740fa6ff000018d62f122aa /weed/replication | |
| parent | 5e07afb0f0c1eca20da0780c806973db40ea6a24 (diff) | |
| parent | 36348114084e7ff583f52ef93a73e1cd8c8f58b5 (diff) | |
| download | seaweedfs-2266b5c5286fd4e70d05fc4c5c64cd617809982f.tar.xz seaweedfs-2266b5c5286fd4e70d05fc4c5c64cd617809982f.zip | |
Merge pull request #1761 from kmlebedev/todaysDateFormat
replication to todays date directory
Diffstat (limited to 'weed/replication')
| -rw-r--r-- | weed/replication/sink/localsink/local_sink.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/weed/replication/sink/localsink/local_sink.go b/weed/replication/sink/localsink/local_sink.go index 76e0384e5..5ca562ec8 100644 --- a/weed/replication/sink/localsink/local_sink.go +++ b/weed/replication/sink/localsink/local_sink.go @@ -12,11 +12,13 @@ import ( "os" "path/filepath" "strings" + "time" ) type LocalSink struct { - dir string - filerSource *source.FilerSource + dir string + todaysDateFormat string + filerSource *source.FilerSource } func init() { @@ -35,18 +37,23 @@ func (localsink *LocalSink) isMultiPartEntry(key string) bool { return strings.HasSuffix(key, ".part") && strings.Contains(key, "/.uploads/") } -func (localsink *LocalSink) initialize(dir string) error { +func (localsink *LocalSink) initialize(dir string, todaysDateFormat string) error { localsink.dir = dir + localsink.todaysDateFormat = todaysDateFormat 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) + return localsink.initialize(dir, todaysDateFormat) } func (localsink *LocalSink) GetSinkToDirectory() string { + if localsink.todaysDateFormat != "" { + return filepath.Join(localsink.dir, time.Now().Format(localsink.todaysDateFormat)) + } return localsink.dir } @@ -56,7 +63,7 @@ func (localsink *LocalSink) DeleteEntry(key string, isDirectory, deleteIncludeCh } glog.V(4).Infof("Delete Entry key: %s", key) if err := os.Remove(key); err != nil { - return err + glog.V(0).Infof("remove entry key %s: %s", key, err) } return nil } |
