Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[server] Fix key look up

Neeraj Guptada09a5261bd0
diff --git a/server/configurations/local.yaml b/server/configurations/local.yaml
index 9e26d820f8..1adad9e775 100644
--- a/server/configurations/local.yaml
+++ b/server/configurations/local.yaml
@@ -174,7 +174,7 @@ s3:
#use_path_style_urls: true
#
# file-data-storage:
- # derivedMetadata:
+ # derivedMeta:
# primaryBucket:
# replicaBuckets: []
# img_preview:
diff --git a/server/pkg/utils/s3config/filedata.go b/server/pkg/utils/s3config/filedata.go
index a39501ba40..fca1ecbcf3 100644
--- a/server/pkg/utils/s3config/filedata.go
+++ b/server/pkg/utils/s3config/filedata.go
@@ -3,6 +3,7 @@ package s3config
import (
"fmt"
"github.com/ente-io/museum/ente"
+ "strings"
)
type ObjectBucketConfig struct {
@@ -11,19 +12,20 @@ type ObjectBucketConfig struct {
}
type FileDataConfig struct {
- ObjectBucketConfig map[ente.ObjectType]ObjectBucketConfig `mapstructure:"file-data-config"`
+ ObjectBucketConfig map[string]ObjectBucketConfig `mapstructure:"file-data-config"`
}
func (f FileDataConfig) HasConfig(objectType ente.ObjectType) bool {
if objectType == "" || objectType == ente.FILE || objectType == ente.THUMBNAIL {
panic(fmt.Sprintf("Invalid object type: %s", objectType))
}
- _, ok := f.ObjectBucketConfig[objectType]
+
+ _, ok := f.ObjectBucketConfig[strings.ToLower(string(objectType))]
return ok
}
func (f FileDataConfig) GetPrimaryBucketID(objectType ente.ObjectType) string {
- config, ok := f.ObjectBucketConfig[objectType]
+ config, ok := f.ObjectBucketConfig[strings.ToLower(string(objectType))]
if !ok {
panic(fmt.Sprintf("No config for object type: %s, use HasConfig", objectType))
}
@@ -31,7 +33,7 @@ func (f FileDataConfig) GetPrimaryBucketID(objectType ente.ObjectType) string {
}
func (f FileDataConfig) GetReplicaBuckets(objectType ente.ObjectType) []string {
- config, ok := f.ObjectBucketConfig[objectType]
+ config, ok := f.ObjectBucketConfig[strings.ToLower(string(objectType))]
if !ok {
panic(fmt.Sprintf("No config for object type: %s, use HasConfig", objectType))
}
diff --git a/server/pkg/utils/s3config/s3config.go b/server/pkg/utils/s3config/s3config.go
index b6ec9ba2af..b027ffac35 100644
--- a/server/pkg/utils/s3config/s3config.go
+++ b/server/pkg/utils/s3config/s3config.go
@@ -174,7 +174,16 @@ func (config *S3Config) GetBucketID(oType ente.ObjectType) string {
if oType == ente.DerivedMeta || oType == ente.PreviewVideo || oType == ente.PreviewImage {
return config.derivedStorageDC
}
- panic(fmt.Sprintf("No bucket for object type: %s", oType))
+ panic(fmt.Sprintf("ops not supported for type: %s", oType))
+}
+func (config *S3Config) GetReplicatedBuckets(oType ente.ObjectType) []string {
+ if config.fileDataConfig.HasConfig(oType) {
+ return config.fileDataConfig.GetReplicaBuckets(oType)
+ }
+ if oType == ente.DerivedMeta || oType == ente.PreviewVideo || oType == ente.PreviewImage {
+ return []string{}
+ }
+ panic(fmt.Sprintf("ops not supported for object type: %s", oType))
}
func (config *S3Config) IsBucketActive(bucketID string) bool {