tstor/plugins/qbittorrent/daemon/api.go
royalcat 3c0ba3cc9f
Some checks failed
docker / build-docker (push) Failing after 56s
up
2025-06-08 06:18:23 +04:00

56 lines
1.6 KiB
Go

package daemon
import (
"context"
"git.kmsign.ru/royalcat/tstor/plugins/qbittorrent/src/delivery/grpc/proto"
"git.kmsign.ru/royalcat/tstor/server/src/daemon"
"google.golang.org/grpc"
)
var _ daemon.DaemonWithGRPC = (*QBittorrentDaemon)(nil)
// RegisterGRPCService implements daemon.DaemonWithGRPC.
func (d *QBittorrentDaemon) RegisterGRPCService(server grpc.ServiceRegistrar) {
proto.RegisterQBitTorrentServiceServer(server, &grpcService{d: d})
}
type grpcService struct {
d *QBittorrentDaemon
// proto.UnimplementedQBitTorrentServiceServer
}
var _ proto.QBitTorrentServiceServer = (*grpcService)(nil)
// Cleanup implements proto.QBitTorrentServiceServer.
func (g *grpcService) Cleanup(ctx context.Context, req *proto.CleanupRequest) (*proto.CleanupResponse, error) {
hashes, err := g.d.Cleanup(ctx, req.GetAct())
if err != nil {
return nil, err
}
resp := proto.CleanupResponse{}
resp.SetCount(int32(len(hashes)))
resp.SetHashes(hashes)
return &resp, nil
}
// CleanupUnregistred implements proto.QBitTorrentServiceServer.
func (g *grpcService) CleanupUnregistred(ctx context.Context, req *proto.CleanupUnregistredRequest) (*proto.CleanupUnregistredResponse, error) {
hashes, err := g.d.CleanupUnregistred(ctx, req.GetAct())
if err != nil {
return nil, err
}
resp := proto.CleanupUnregistredResponse{}
resp.SetCount(int32(len(hashes)))
resp.SetHashes(hashes)
return &resp, nil
}
// GetTorrents implements proto.QBitTorrentServiceServer.
func (g *grpcService) GetTorrents(context.Context, *proto.GetTorrentsRequest) (*proto.GetTorrentsResponse, error) {
panic("not implemented") // TODO: Implement GetTorrents
}