mirror of
				https://github.com/TheAnachronism/docspell.git
				synced 2025-10-31 09:30:12 +00:00 
			
		
		
		
	| @@ -11,6 +11,7 @@ import cats.implicits._ | ||||
|  | ||||
| import docspell.backend.signup.{Config => SignupConfig} | ||||
| import docspell.common._ | ||||
| import docspell.common.syntax.string._ | ||||
| import docspell.store.file.FileRepositoryConfig | ||||
| import docspell.store.{JdbcConfig, SchemaMigrateConfig} | ||||
|  | ||||
| @@ -51,6 +52,12 @@ object Config { | ||||
|       stores.get(id).map(FileRepositoryConfig.fromFileStoreConfig(chunkSize, _)) | ||||
|  | ||||
|     def validate: ValidatedNec[String, Files] = { | ||||
|       def filterEmptyRegion = | ||||
|         copy(stores = stores.view.mapValues { | ||||
|           case c: FileStoreConfig.S3 => c.copy(region = c.region.flatMap(_.asNonBlank)) | ||||
|           case c                     => c | ||||
|         }.toMap) | ||||
|  | ||||
|       val storesEmpty = | ||||
|         if (enabledStores.isEmpty) | ||||
|           Validated.invalidNec( | ||||
| @@ -65,7 +72,7 @@ object Config { | ||||
|             Validated.invalidNec(s"Default file store not present: ${defaultStore.id}") | ||||
|         } | ||||
|  | ||||
|       (storesEmpty |+| defaultStorePresent).map(_ => this) | ||||
|       (storesEmpty |+| defaultStorePresent).map(_ => filterEmptyRegion) | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -29,11 +29,12 @@ object FileStoreConfig { | ||||
|       endpoint: String, | ||||
|       accessKey: String, | ||||
|       secretKey: String, | ||||
|       region: Option[String], | ||||
|       bucket: String | ||||
|   ) extends FileStoreConfig { | ||||
|     val storeType = FileStoreType.S3 | ||||
|  | ||||
|     override def toString = | ||||
|       s"S3(enabled=$enabled, endpoint=$endpoint, bucket=$bucket, accessKey=$accessKey, secretKey=***)" | ||||
|       s"S3(enabled=$enabled, endpoint=$endpoint, bucket=$bucket, accessKey=$accessKey, secretKey=***, region=$region)" | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -739,6 +739,7 @@ Docpell Update Check | ||||
|          access-key = "username" | ||||
|          secret-key = "password" | ||||
|          bucket = "docspell" | ||||
|          region = "" | ||||
|        } | ||||
|     } | ||||
|   } | ||||
|   | ||||
| @@ -60,7 +60,7 @@ object ConfigFile { | ||||
|         cfg => cfg.updateCheck.enabled && cfg.updateCheck.subject.els.isEmpty, | ||||
|         "No subject given for enabled update check!" | ||||
|       ), | ||||
|       Validation(cfg => cfg.files.validate.map(_ => cfg)), | ||||
|       Validation(cfg => cfg.files.validate.map(f => cfg.copy(files = f))), | ||||
|       Validation.failWhen( | ||||
|         cfg => | ||||
|           cfg.fullTextSearch.enabled && | ||||
|   | ||||
| @@ -493,6 +493,7 @@ docspell.server { | ||||
|            access-key = "username" | ||||
|            secret-key = "password" | ||||
|            bucket = "docspell" | ||||
|            region = "" | ||||
|          } | ||||
|       } | ||||
|     } | ||||
|   | ||||
| @@ -113,7 +113,9 @@ object ConfigFile { | ||||
|     } | ||||
|  | ||||
|   def filesValidate: Validation[Config] = | ||||
|     Validation(cfg => cfg.backend.files.validate.map(_ => cfg)) | ||||
|     Validation(cfg => | ||||
|       cfg.backend.files.validate.map(f => cfg.copy(backend = cfg.backend.copy(files = f))) | ||||
|     ) | ||||
|  | ||||
|   def postgresFtsValidate: Validation[Config] = | ||||
|     Validation.failWhen( | ||||
|   | ||||
| @@ -108,11 +108,22 @@ object BinnyUtils { | ||||
|           JdbcStoreConfig("filechunk", chunkSize, BinnyUtils.TikaContentTypeDetect) | ||||
|         GenericJdbcStore[F](ds, LoggerAdapter(logger), jdbcConfig) | ||||
|  | ||||
|       case FileRepositoryConfig.S3(endpoint, accessKey, secretKey, bucket, chunkSize) => | ||||
|       case FileRepositoryConfig.S3( | ||||
|             endpoint, | ||||
|             accessKey, | ||||
|             secretKey, | ||||
|             bucket, | ||||
|             region, | ||||
|             chunkSize | ||||
|           ) => | ||||
|         val keyMapping = S3KeyMapping.constant(bucket) | ||||
|         val minioCfg = MinioConfig | ||||
|           .default(endpoint, accessKey, secretKey, keyMapping) | ||||
|           .copy(chunkSize = chunkSize, detect = BinnyUtils.TikaContentTypeDetect) | ||||
|           .copy( | ||||
|             chunkSize = chunkSize, | ||||
|             detect = BinnyUtils.TikaContentTypeDetect, | ||||
|             region = region | ||||
|           ) | ||||
|  | ||||
|         MinioBinaryStore[F](minioCfg, LoggerAdapter(logger)) | ||||
|  | ||||
|   | ||||
| @@ -10,7 +10,7 @@ import fs2.io.file.Path | ||||
|  | ||||
| import docspell.common.FileStoreConfig | ||||
|  | ||||
| sealed trait FileRepositoryConfig {} | ||||
| sealed trait FileRepositoryConfig | ||||
|  | ||||
| object FileRepositoryConfig { | ||||
|  | ||||
| @@ -21,6 +21,7 @@ object FileRepositoryConfig { | ||||
|       accessKey: String, | ||||
|       secretKey: String, | ||||
|       bucketName: String, | ||||
|       region: Option[String], | ||||
|       chunkSize: Int | ||||
|   ) extends FileRepositoryConfig | ||||
|  | ||||
| @@ -30,8 +31,15 @@ object FileRepositoryConfig { | ||||
|     cfg match { | ||||
|       case FileStoreConfig.DefaultDatabase(_) => | ||||
|         FileRepositoryConfig.Database(chunkSize) | ||||
|       case FileStoreConfig.S3(_, endpoint, accessKey, secretKey, bucket) => | ||||
|         FileRepositoryConfig.S3(endpoint, accessKey, secretKey, bucket, chunkSize) | ||||
|       case FileStoreConfig.S3(_, endpoint, accessKey, secretKey, region, bucket) => | ||||
|         FileRepositoryConfig.S3( | ||||
|           endpoint, | ||||
|           accessKey, | ||||
|           secretKey, | ||||
|           bucket, | ||||
|           region.map(_.trim).filter(_.nonEmpty), | ||||
|           chunkSize | ||||
|         ) | ||||
|       case FileStoreConfig.FileSystem(_, directory) => | ||||
|         FileRepositoryConfig.Directory(directory, chunkSize) | ||||
|     } | ||||
|   | ||||
| @@ -73,6 +73,7 @@ files { | ||||
|        access-key = "username" | ||||
|        secret-key = "password" | ||||
|        bucket = "docspell" | ||||
|        # region = "…" | ||||
|      } | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -54,8 +54,8 @@ For linuxes, the default location is `~/.config/dsc/config.toml`. You | ||||
| can give a config file explicitly via an option or the environment | ||||
| variable `DSC_CONFIG`. | ||||
|  | ||||
| If you use the [pass](https://passwordstore.org) password manager, you | ||||
| can add your password entry to the config file as well. | ||||
| If you use the [pass](https://www.passwordstore.org) password manager, | ||||
| you can add your password entry to the config file as well. | ||||
|  | ||||
| ## Output format | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user