mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Make file upload limits configurable (#1079)
This commit is contained in:
@@ -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"))
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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. |
|
||||
|
||||
Reference in New Issue
Block a user