make replication.worker-url optional

This commit is contained in:
Kermina Awad 2024-06-22 12:49:35 -04:00
parent de36d1f9fb
commit 81b07e772d
2 changed files with 5 additions and 4 deletions

View File

@ -317,7 +317,7 @@ internal:
replication:
enabled: false
# The Cloudflare worker to use to download files from the primary hot
# bucket. Must be specified if replication is enabled.
# bucket. If this isn't specified, files will be downloaded directly.
worker-url:
# Number of go routines to spawn for replication
# This is not related to the worker-url above.

View File

@ -87,10 +87,11 @@ func (c *ReplicationController3) StartReplication() error {
workerURL := viper.GetString("replication.worker-url")
if workerURL == "" {
return fmt.Errorf("replication.worker-url was not defined")
log.Infof("replication.worker-url was not defined, files will downloaded directly during replication")
} else {
log.Infof("Worker URL to download objects for replication v3 is: %s", workerURL)
}
c.workerURL = workerURL
log.Infof("Worker URL to download objects for replication v3 is: %s", workerURL)
c.createMetrics()
err := c.createTemporaryStorage()
@ -414,7 +415,7 @@ func (c *ReplicationController3) downloadFromB2ViaWorker(objectKey string, file
q.Add("src", presignedEncodedURL)
request.URL.RawQuery = q.Encode()
if c.S3Config.AreLocalBuckets() {
if c.S3Config.AreLocalBuckets() || c.workerURL == "" {
originalURL := request.URL
request, err = http.NewRequest("GET", presignedURL, nil)
if err != nil {