diff --git a/weed/filer/filer_conf.go b/weed/filer/filer_conf.go index 25bf83771..69755a16a 100644 --- a/weed/filer/filer_conf.go +++ b/weed/filer/filer_conf.go @@ -102,7 +102,7 @@ func (fc *FilerConf) LoadFromBytes(data []byte) (err error) { func (fc *FilerConf) doLoadConf(conf *filer_pb.FilerConf) (err error) { for _, location := range conf.Locations { - err = fc.AddLocationConf(location) + err = fc.SetLocationConf(location) if err != nil { // this is not recoverable return nil @@ -111,7 +111,24 @@ func (fc *FilerConf) doLoadConf(conf *filer_pb.FilerConf) (err error) { return nil } +func (fc *FilerConf) GetLocationConf(locationPrefix string)(locConf *filer_pb.FilerConf_PathConf, found bool) { + return fc.rules.Get([]byte(locationPrefix)) +} + +func (fc *FilerConf) SetLocationConf(locConf *filer_pb.FilerConf_PathConf) (err error) { + err = fc.rules.Put([]byte(locConf.LocationPrefix), locConf) + if err != nil { + glog.Errorf("put location prefix: %v", err) + } + return +} + func (fc *FilerConf) AddLocationConf(locConf *filer_pb.FilerConf_PathConf) (err error) { + existingConf, found := fc.rules.Get([]byte(locConf.LocationPrefix)) + if found { + mergePathConf(existingConf, locConf) + locConf = existingConf + } err = fc.rules.Put([]byte(locConf.LocationPrefix), locConf) if err != nil { glog.Errorf("put location prefix: %v", err) @@ -170,6 +187,7 @@ func mergePathConf(a, b *filer_pb.FilerConf_PathConf) { a.DataCenter = util.Nvl(b.DataCenter, a.DataCenter) a.Rack = util.Nvl(b.Rack, a.Rack) a.DataNode = util.Nvl(b.DataNode, a.DataNode) + a.DisableChunkDeletion = b.DisableChunkDeletion || a.DisableChunkDeletion } func (fc *FilerConf) ToProto() *filer_pb.FilerConf { diff --git a/weed/s3api/s3api_bucket_handlers.go b/weed/s3api/s3api_bucket_handlers.go index f451e60a2..7d0d76ea4 100644 --- a/weed/s3api/s3api_bucket_handlers.go +++ b/weed/s3api/s3api_bucket_handlers.go @@ -455,7 +455,11 @@ func (s3a *S3ApiServer) DeleteBucketLifecycleHandler(w http.ResponseWriter, r *h for prefix, ttl := range collectionTtls { bucketPrefix := fmt.Sprintf("%s/%s/", s3a.option.BucketsPath, bucket) if strings.HasPrefix(prefix, bucketPrefix) && strings.HasSuffix(ttl, "d") { - fc.DeleteLocationConf(prefix) + pathConf, found := fc.GetLocationConf(prefix) + if found { + pathConf.Ttl = "" + fc.SetLocationConf(pathConf) + } changed = true } } diff --git a/weed/shell/command_s3_bucket_quota_check.go b/weed/shell/command_s3_bucket_quota_check.go index bc0d838f7..b130e4fad 100644 --- a/weed/shell/command_s3_bucket_quota_check.go +++ b/weed/shell/command_s3_bucket_quota_check.go @@ -130,7 +130,7 @@ func (c *commandS3BucketQuotaEnforce) processEachBucket(fc *filer.FilerConf, fil } else { fmt.Fprintf(writer, " changing bucket %s to writable.\n", entry.Name) } - fc.AddLocationConf(locConf) + fc.SetLocationConf(locConf) } return