diff --git a/pkg/api/server.go b/pkg/api/server.go index 5fe5b2784..0fc201cc6 100644 --- a/pkg/api/server.go +++ b/pkg/api/server.go @@ -134,12 +134,13 @@ func Start() { return true }, }) + maxUploadSize := handler.UploadMaxSize(config.GetMaxUploadSize()) txnManager := manager.GetInstance().TxnManager resolver := &Resolver{ txnManager: txnManager, } - gqlHandler := handler.GraphQL(models.NewExecutableSchema(models.Config{Resolvers: resolver}), recoverFunc, websocketUpgrader) + gqlHandler := handler.GraphQL(models.NewExecutableSchema(models.Config{Resolvers: resolver}), recoverFunc, websocketUpgrader, maxUploadSize) r.Handle("/graphql", gqlHandler) r.Handle("/playground", handler.Playground("GraphQL playground", "/graphql")) diff --git a/pkg/manager/config/config.go b/pkg/manager/config/config.go index 622500bec..6ef58f6b9 100644 --- a/pkg/manager/config/config.go +++ b/pkg/manager/config/config.go @@ -120,6 +120,9 @@ const LogOut = "logOut" const LogLevel = "logLevel" const LogAccess = "logAccess" +// File upload options +const MaxUploadSize = "max_upload_size" + func Set(key string, value interface{}) { viper.Set(key, value) } @@ -579,6 +582,15 @@ func GetLogAccess() bool { return ret } +// Max allowed graphql upload size in megabytes +func GetMaxUploadSize() int64 { + ret := int64(1024) + if viper.IsSet(MaxUploadSize) { + ret = viper.GetInt64(MaxUploadSize) + } + return ret << 20 +} + func IsValid() bool { setPaths := viper.IsSet(Stash) && viper.IsSet(Cache) && viper.IsSet(Generated) && viper.IsSet(Metadata) diff --git a/pkg/manager/task_import.go b/pkg/manager/task_import.go index 6e9a4489f..77eefde62 100644 --- a/pkg/manager/task_import.go +++ b/pkg/manager/task_import.go @@ -172,17 +172,21 @@ func (t *ImportTask) unzipFile() error { if err != nil { return err } - defer o.Close() i, err := f.Open() if err != nil { + o.Close() return err } - defer i.Close() if _, err := io.Copy(o, i); err != nil { + o.Close() + i.Close() return err } + + o.Close() + i.Close() } return nil diff --git a/pkg/models/sql.go b/pkg/models/sql.go index af7f8374e..ea33f3245 100644 --- a/pkg/models/sql.go +++ b/pkg/models/sql.go @@ -14,4 +14,4 @@ func NullInt64(v int64) sql.NullInt64 { Int64: v, Valid: true, } -} \ No newline at end of file +} diff --git a/ui/v2.5/src/components/Changelog/versions/v050.md b/ui/v2.5/src/components/Changelog/versions/v050.md index 0efc790f2..45b244cf1 100644 --- a/ui/v2.5/src/components/Changelog/versions/v050.md +++ b/ui/v2.5/src/components/Changelog/versions/v050.md @@ -7,6 +7,7 @@ * Allow configuration of visible navbar items. ### 🎨 Improvements +* Added configuration option for import file size limit and increased default to 1GB. * Add dry-run option for Clean task. * Refresh UI when changing custom CSS options. * Add batch deleting of performers, tags, studios, and movies. diff --git a/ui/v2.5/src/docs/en/Configuration.md b/ui/v2.5/src/docs/en/Configuration.md index 81d5e3c30..ac5f7d596 100644 --- a/ui/v2.5/src/docs/en/Configuration.md +++ b/ui/v2.5/src/docs/en/Configuration.md @@ -103,3 +103,10 @@ Stash saves login credentials in the config.yml file. You must reset both login * Delete the `login` and `password` lines from the file and save Stash authentication should now be reset with no authentication credentials. +## Advanced configuration options + +These options are typically not exposed in the UI and must be changed manually in the `config.yml` file. + +| Field | Remarks | +|-------|---------| +| `max_upload_size` | Maximum file upload size for import files. Defaults to 1GB. |