mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Separate graphql API from rest of the system (#2503)
* Move graphql generated files to api * Refactor identify options * Remove models.StashBoxes * Move ScraperSource to scraper package * Rename field strategy enums * Rename identify.TaskOptions to Options
This commit is contained in:
@@ -1,6 +1,53 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
type HashAlgorithm string
|
||||
|
||||
const (
|
||||
HashAlgorithmMd5 HashAlgorithm = "MD5"
|
||||
// oshash
|
||||
HashAlgorithmOshash HashAlgorithm = "OSHASH"
|
||||
)
|
||||
|
||||
var AllHashAlgorithm = []HashAlgorithm{
|
||||
HashAlgorithmMd5,
|
||||
HashAlgorithmOshash,
|
||||
}
|
||||
|
||||
func (e HashAlgorithm) IsValid() bool {
|
||||
switch e {
|
||||
case HashAlgorithmMd5, HashAlgorithmOshash:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (e HashAlgorithm) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e *HashAlgorithm) UnmarshalGQL(v interface{}) error {
|
||||
str, ok := v.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("enums must be strings")
|
||||
}
|
||||
|
||||
*e = HashAlgorithm(str)
|
||||
if !e.IsValid() {
|
||||
return fmt.Errorf("%s is not a valid HashAlgorithm", str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e HashAlgorithm) MarshalGQL(w io.Writer) {
|
||||
fmt.Fprint(w, strconv.Quote(e.String()))
|
||||
}
|
||||
|
||||
type File struct {
|
||||
Checksum string `db:"checksum" json:"checksum"`
|
||||
|
||||
Reference in New Issue
Block a user