From 7f63517d481e49ced4fed6aff6dafee4701c7f1f Mon Sep 17 00:00:00 2001 From: Travis Ralston <travpc@gmail.com> Date: Sat, 18 Jul 2020 12:32:32 -0600 Subject: [PATCH] Don't estimate datastore size when there's only one datastore --- CHANGELOG.md | 1 + storage/datastore/datastore.go | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 024d91d8..bb8e8e32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), * GIFs now thumbnail correctly. Thanks @Sorunome! * Fixed empty Content-Type header on retrieved remote media. Thanks @silkeh! * Fixed various issues with IPv6 handling. Thanks @silkeh! +* Fixed high database usage for uploads when only one datastore is present. ## [1.1.3] - July 15th, 2020 diff --git a/storage/datastore/datastore.go b/storage/datastore/datastore.go index 9896c5b5..ff6b1a19 100644 --- a/storage/datastore/datastore.go +++ b/storage/datastore/datastore.go @@ -94,7 +94,6 @@ func GetUriForDatastore(dsConf config.DatastoreConfig) string { } func PickDatastore(forKind string, ctx rcontext.RequestContext) (*DatastoreRef, error) { - // If we haven't found a legacy option, pick a datastore ctx.Log.Info("Finding a suitable datastore to pick for " + forKind) confDatastores := ctx.Config.DataStores mediaStore := storage.GetDatabase().GetMediaStore(ctx) @@ -122,9 +121,13 @@ func PickDatastore(forKind string, ctx rcontext.RequestContext) (*DatastoreRef, continue } - size, err := estimatedDatastoreSize(ds, ctx) - if err != nil { - continue + var size int64 + + if len(confDatastores) > 1 { + size, err = estimatedDatastoreSize(ds, ctx) + if err != nil { + continue + } } if targetDs == nil || size < dsSize { -- GitLab