package resolver // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.49 import ( "context" graph "git.kmsign.ru/royalcat/tstor/src/delivery/graphql" "git.kmsign.ru/royalcat/tstor/src/delivery/graphql/model" "github.com/anacrolix/torrent/types" ) // ValidateTorrent is the resolver for the validateTorrent field. func (r *torrentDaemonMutationResolver) ValidateTorrent(ctx context.Context, obj *model.TorrentDaemonMutation, filter model.TorrentFilter) (bool, error) { if filter.Infohash != nil { t, err := r.Resolver.Service.GetTorrent(*filter.Infohash) if err != nil { return false, err } if t == nil { return false, nil } t.ValidateTorrent(ctx) return true, nil } if filter.Everything != nil && *filter.Everything { torrents, err := r.Resolver.Service.ListTorrents(ctx) if err != nil { return false, err } for _, v := range torrents { if err := v.ValidateTorrent(ctx); err != nil { return false, err } } return true, nil } return false, nil } // SetTorrentPriority is the resolver for the setTorrentPriority field. func (r *torrentDaemonMutationResolver) SetTorrentPriority(ctx context.Context, obj *model.TorrentDaemonMutation, infohash string, file *string, priority types.PiecePriority) (bool, error) { t, err := r.Resolver.Service.GetTorrent(infohash) if err != nil { return false, err } if t == nil { return false, nil } err = t.SetPriority(ctx, file, priority) if err != nil { return false, err } return true, nil } // Cleanup is the resolver for the cleanup field. func (r *torrentDaemonMutationResolver) Cleanup(ctx context.Context, obj *model.TorrentDaemonMutation, files *bool, dryRun bool) (*model.CleanupResponse, error) { torrents, err := r.Service.ListTorrents(ctx) if err != nil { return nil, err } if files != nil && *files { r, err := r.Service.Storage.CleanupFiles(ctx, torrents, dryRun) return &model.CleanupResponse{ Count: int64(len(r)), List: r, }, err } else { r, err := r.Service.Storage.CleanupDirs(ctx, torrents, dryRun) return &model.CleanupResponse{ Count: int64(len(r)), List: r, }, err } } // TorrentDaemonMutation returns graph.TorrentDaemonMutationResolver implementation. func (r *Resolver) TorrentDaemonMutation() graph.TorrentDaemonMutationResolver { return &torrentDaemonMutationResolver{r} } type torrentDaemonMutationResolver struct{ *Resolver }