mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-22 19:09:58 +00:00
feature/taildrop: do not use m.opts.Dir for Android (#16316)
In Android, we are prompting the user to select a Taildrop directory when they first receive a Taildrop: we block writes on Taildrop dir selection. This means that we cannot use Dir inside managerOptions, since the http request would not get the new Taildrop extension. This PR removes, in the Android case, the reliance on m.opts.Dir, and instead has FileOps hold the correct directory. This expands FileOps to be the Taildrop interface for all file system operations. Updates tailscale/corp#29211 Signed-off-by: kari-ts <kari@tailscale.com> restore tstest
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"io"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"testing/iotest"
|
||||
|
||||
@@ -19,7 +20,9 @@ func TestResume(t *testing.T) {
|
||||
defer func() { blockSize = oldBlockSize }()
|
||||
blockSize = 256
|
||||
|
||||
m := managerOptions{Logf: t.Logf, Dir: t.TempDir()}.New()
|
||||
dir := t.TempDir()
|
||||
|
||||
m := managerOptions{Logf: t.Logf, fileOps: must.Get(newFileOps(dir))}.New()
|
||||
defer m.Shutdown()
|
||||
|
||||
rn := rand.New(rand.NewSource(0))
|
||||
@@ -37,7 +40,7 @@ func TestResume(t *testing.T) {
|
||||
must.Do(close()) // Windows wants the file handle to be closed to rename it.
|
||||
|
||||
must.Get(m.PutFile("", "foo", r, offset, -1))
|
||||
got := must.Get(os.ReadFile(must.Get(joinDir(m.opts.Dir, "foo"))))
|
||||
got := must.Get(os.ReadFile(filepath.Join(dir, "foo")))
|
||||
if !bytes.Equal(got, want) {
|
||||
t.Errorf("content mismatches")
|
||||
}
|
||||
@@ -66,7 +69,7 @@ func TestResume(t *testing.T) {
|
||||
t.Fatalf("too many iterations to complete the test")
|
||||
}
|
||||
}
|
||||
got := must.Get(os.ReadFile(must.Get(joinDir(m.opts.Dir, "bar"))))
|
||||
got := must.Get(os.ReadFile(filepath.Join(dir, "bar")))
|
||||
if !bytes.Equal(got, want) {
|
||||
t.Errorf("content mismatches")
|
||||
}
|
||||
|
Reference in New Issue
Block a user