From bca9c555f4a91503933dd04712caadebf64a597b Mon Sep 17 00:00:00 2001
From: Travis Ralston <travpc@gmail.com>
Date: Sat, 30 May 2020 22:51:21 -0600
Subject: [PATCH] Remove storagePaths support

---
 CHANGELOG.md                     |  1 +
 common/config/conf_min_shared.go |  1 -
 common/config/models_domain.go   |  1 -
 common/runtime/init.go           | 24 ------------------------
 config.sample.yaml               |  7 -------
 5 files changed, 1 insertion(+), 33 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index c1ac8086..e966a768 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 ### Changed
 
 * Deprecated support for restricting uploads to certain mime types, due to inability to make it work correctly with encrypted media.
+* Removed deprecated `storagePaths` config option. Please use datastores.
 
 ### Fixed
 
diff --git a/common/config/conf_min_shared.go b/common/config/conf_min_shared.go
index 8531219f..8c8a79cf 100644
--- a/common/config/conf_min_shared.go
+++ b/common/config/conf_min_shared.go
@@ -23,7 +23,6 @@ func NewDefaultMinimumRepoConfig() MinimumRepoConfig {
 			MaxSizeBytes:         104857600, // 100mb
 			MinSizeBytes:         100,
 			ReportedMaxSizeBytes: 0,
-			StoragePaths:         []string{},
 			AllowedTypes:         []string{"*/*"},
 		},
 		Identicons: IdenticonsConfig{
diff --git a/common/config/models_domain.go b/common/config/models_domain.go
index bf8ad4b6..e677ef46 100644
--- a/common/config/models_domain.go
+++ b/common/config/models_domain.go
@@ -7,7 +7,6 @@ type ArchivingConfig struct {
 }
 
 type UploadsConfig struct {
-	StoragePaths         []string            `yaml:"storagePaths,flow"` // deprecated
 	MaxSizeBytes         int64               `yaml:"maxBytes"`
 	MinSizeBytes         int64               `yaml:"minBytes"`
 	AllowedTypes         []string            `yaml:"allowedTypes,flow"`
diff --git a/common/runtime/init.go b/common/runtime/init.go
index ea07c90f..fdb6bcbd 100644
--- a/common/runtime/init.go
+++ b/common/runtime/init.go
@@ -4,7 +4,6 @@ import (
 	"fmt"
 
 	"github.com/sirupsen/logrus"
-	"github.com/turt2live/matrix-media-repo/common"
 	"github.com/turt2live/matrix-media-repo/common/config"
 	"github.com/turt2live/matrix-media-repo/common/rcontext"
 	"github.com/turt2live/matrix-media-repo/common/version"
@@ -31,25 +30,6 @@ func LoadDatabase() {
 }
 
 func LoadDatastores() {
-	if len(config.Get().Uploads.StoragePaths) > 0 {
-		logrus.Warn("storagePaths usage is deprecated - please use datastores instead")
-		for _, p := range config.Get().Uploads.StoragePaths {
-			ctx := rcontext.Initial().LogWithFields(logrus.Fields{"path": p})
-			ds, err := storage.GetOrCreateDatastoreOfType(ctx, "file", p)
-			if err != nil {
-				logrus.Fatal(err)
-			}
-
-			fakeConfig := config.DatastoreConfig{
-				Type:       "file",
-				Enabled:    true,
-				MediaKinds: common.AllKinds,
-				Options:    map[string]string{"path": ds.Uri},
-			}
-			config.Get().DataStores = append(config.Get().DataStores, fakeConfig)
-		}
-	}
-
 	mediaStore := storage.GetDatabase().GetMediaStore(rcontext.Initial())
 
 	logrus.Info("Initializing datastores...")
@@ -97,8 +77,4 @@ func LoadDatastores() {
 			}
 		}
 	}
-
-	if len(config.Get().Uploads.StoragePaths) > 0 {
-		logrus.Warn("You are using `storagePaths` in your configuration - in a future update, this will be removed. Please use datastores instead (see sample config).")
-	}
 }
diff --git a/config.sample.yaml b/config.sample.yaml
index 2ba58699..dce572ec 100644
--- a/config.sample.yaml
+++ b/config.sample.yaml
@@ -208,13 +208,6 @@ uploads:
   # Set this to -1 to indicate that there is no limit. Zero will force the use of maxBytes.
   #reportedMaxBytes: 104857600
 
-  # This is intended for larger deployments where media should be distributed among other
-  # directories, drives, servers, etc. For smaller deployments, a single entry in this list
-  # is recommended.
-  # DEPRECATED: Use datastores instead.
-  #storagePaths:
-  #  - /var/matrix/media
-
   # An optional list of file types that are allowed to be uploaded. If */* or nothing is
   # supplied here, then all file types are allowed. Asterisks (*) are wildcards and can be
   # placed anywhere to match everything (eg: "image/*" matches all images). This will also
-- 
GitLab