Documentation ¶
Overview ¶
Package filetransfer implements the exchange of files between cdgb <-> debugd and between debugd <-> debugd pairs.
Index ¶
Constants ¶
const ( // ShowProgress indicates that progress should be shown. ShowProgress = true // DontShowProgress indicates that progress should not be shown. DontShowProgress = false )
Variables ¶
var ( // ErrReceiveRunning is returned if a file receive is already running. ErrReceiveRunning = errors.New("receive already running") // ErrReceiveFinished is returned if a file receive has already finished. ErrReceiveFinished = errors.New("receive finished") )
Functions ¶
This section is empty.
Types ¶
type FileStat ¶
type FileStat struct { SourcePath string TargetPath string Mode fs.FileMode OverrideServiceUnit string // optional name of the service unit to override }
FileStat contains the metadata of a file that can be up/downloaded.
type FileTransferer ¶
type FileTransferer struct {
// contains filtered or unexported fields
}
FileTransferer manages sending and receiving of files.
func New ¶
func New(log *slog.Logger, streamer streamReadWriter, showProgress bool) *FileTransferer
New creates a new FileTransferer.
func (*FileTransferer) GetFiles ¶
func (s *FileTransferer) GetFiles() []FileStat
GetFiles returns the a copy of the list of files that have been received.
func (*FileTransferer) RecvFiles ¶
func (s *FileTransferer) RecvFiles(stream RecvFilesStream) (err error)
RecvFiles receives files from the given stream.
func (*FileTransferer) SendFiles ¶
func (s *FileTransferer) SendFiles(stream SendFilesStream) error
SendFiles sends files to the given stream. If the FileTransferer has not received any files to send, an error is returned.
func (*FileTransferer) SetFiles ¶
func (s *FileTransferer) SetFiles(files []FileStat)
SetFiles sets the list of files that can be sent. This function is used for a sender which has not received any files through this FileTransferer i.e. the CLI.
type RecvFilesStream ¶
type RecvFilesStream interface {
Recv() (*pb.FileTransferMessage, error)
}
RecvFilesStream is a stream that receives FileTransferMessages.
type SendFilesStream ¶
type SendFilesStream interface {
Send(*pb.FileTransferMessage) error
}
SendFilesStream is a stream that sends FileTransferMessages.