diff --git a/CHANGELOG.md b/CHANGELOG.md index 024d91d8b4e5c49f3ac37905570b9b2769068cfc..bb8e8e3286db807cf95ec76aa80d59966025d8e1 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 9896c5b5a1a2e2d5593a38662129c9947ef8e799..ff6b1a198b0a12ef5dd618d573e8f5ea863fcd07 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 {