2019-03-23 21:09:05 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"github.com/stashapp/stash/pkg/manager/config"
|
|
|
|
"github.com/stashapp/stash/pkg/models"
|
|
|
|
"github.com/stashapp/stash/pkg/utils"
|
|
|
|
)
|
|
|
|
|
2019-03-26 15:35:06 +00:00
|
|
|
func (r *queryResolver) Configuration(ctx context.Context) (*models.ConfigResult, error) {
|
2019-03-23 21:09:05 +00:00
|
|
|
return makeConfigResult(), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *queryResolver) Directories(ctx context.Context, path *string) ([]string, error) {
|
|
|
|
var dirPath = ""
|
|
|
|
if path != nil {
|
|
|
|
dirPath = *path
|
|
|
|
}
|
|
|
|
return utils.ListDir(dirPath), nil
|
|
|
|
}
|
|
|
|
|
2019-03-26 15:35:06 +00:00
|
|
|
func makeConfigResult() *models.ConfigResult {
|
|
|
|
return &models.ConfigResult{
|
|
|
|
General: *makeConfigGeneralResult(),
|
2019-03-23 21:09:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-26 15:35:06 +00:00
|
|
|
func makeConfigGeneralResult() *models.ConfigGeneralResult {
|
|
|
|
return &models.ConfigGeneralResult{
|
2019-03-24 17:04:31 +00:00
|
|
|
Stashes: config.GetStashPaths(),
|
|
|
|
DatabasePath: config.GetDatabasePath(),
|
|
|
|
GeneratedPath: config.GetGeneratedPath(),
|
2019-03-23 21:09:05 +00:00
|
|
|
}
|
2019-03-24 17:04:31 +00:00
|
|
|
}
|