Skip to content

armgit / ente

Public Imported from GitHub
0

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

fileData: Use primary bucket as preferred bucket to read

Neeraj Gupta868c45baa413
diff --git a/server/pkg/controller/filedata/controller.go b/server/pkg/controller/filedata/controller.go
index 65cbef0033..9c192d7495 100644
--- a/server/pkg/controller/filedata/controller.go
+++ b/server/pkg/controller/filedata/controller.go
@@ -22,6 +22,7 @@ import (
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
"net/http"
+ "strings"
"sync"
gTime "time"
)
@@ -264,12 +265,12 @@ func (c *Controller) getS3FileMetadataParallel(ctx *gin.Context, dbRows []fileDa
func (c *Controller) fetchS3FileMetadata(ctx context.Context, row fileData.Row, ctxLogger *log.Entry) (*fileData.S3FileMetadata, error) {
dc := row.LatestBucket
- // :todo:neeraj make it configurable to
- // specify preferred dc to read from
- // and fallback logic to read from different bucket when we fail to read from preferred dc
- if dc == "b5" {
- if array.StringInList("b6", row.ReplicatedBuckets) {
- dc = "b6"
+ preferredBucket := c.S3Config.GetBucketID(row.Type)
+ // If the current primary bucket is different from the latest bucket where data was written,
+ // check and use the preferred bucket if the data is replicated there.
+ if !strings.EqualFold(preferredBucket, dc) {
+ if array.StringInList(preferredBucket, row.ReplicatedBuckets) {
+ dc = preferredBucket
}
}
opt := _defaultFetchConfig