From 21a6b02ed4132acbaa45a9ff82be8028593e2c5e Mon Sep 17 00:00:00 2001 From: Jonathan Nobels Date: Wed, 27 Mar 2024 10:00:29 -0400 Subject: [PATCH] taildrop: include the absolute path in WaitingFiles updates ENG-2868 including the source path for waiting files allows capable clients to move temporary taildrop files to the users's chosen location directly, rather than using the /files GET and DELETE endpoints. Signed-off-by: Jonathan Nobels --- client/tailscale/apitype/apitype.go | 11 +++++++++-- taildrop/retrieve.go | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/client/tailscale/apitype/apitype.go b/client/tailscale/apitype/apitype.go index 6458f510b..3089486a0 100644 --- a/client/tailscale/apitype/apitype.go +++ b/client/tailscale/apitype/apitype.go @@ -30,9 +30,16 @@ type FileTarget struct { PeerAPIURL string } +// WaitingFiles represent taildrop files sent to the node, ready to be +// copied to their permenant location by the client. The client may +// opt to handle these these using either the /files GET and DELETE +// endpoints or by moving the file if the client has read/write +// access to the AbsolutePath. The client is responsible for removing +// the file when they have finished processing it. type WaitingFile struct { - Name string - Size int64 + Name string + Size int64 + AbsolutePath string } // SetPushDeviceTokenRequest is the body POSTed to the LocalAPI endpoint /set-device-token. diff --git a/taildrop/retrieve.go b/taildrop/retrieve.go index 3e37b492a..96a7d2111 100644 --- a/taildrop/retrieve.go +++ b/taildrop/retrieve.go @@ -80,8 +80,9 @@ func (m *Manager) WaitingFiles() (ret []apitype.WaitingFile, err error) { return true } ret = append(ret, apitype.WaitingFile{ - Name: filepath.Base(name), - Size: fi.Size(), + AbsolutePath: filepath.Join(m.opts.Dir, name), + Name: filepath.Base(name), + Size: fi.Size(), }) } return true