cmd/uplink: disable deleting local files
Change-Id: Id3687f3346f8ec9b5da5459a57d91d1d30bf5566
This commit is contained in:
parent
8bd9a079e4
commit
e00423e2e9
@ -63,6 +63,10 @@ func (c *cmdRm) Setup(params clingy.Parameters) {
|
||||
}
|
||||
|
||||
func (c *cmdRm) Execute(ctx clingy.Context) error {
|
||||
if c.location.Local() {
|
||||
return errs.New("remove %v skipped: local delete", c.location)
|
||||
}
|
||||
|
||||
fs, err := c.ex.OpenFilesystem(ctx, c.access, ulext.BypassEncryption(c.encrypted))
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -76,9 +76,10 @@ func TestRmLocal(t *testing.T) {
|
||||
ultest.WithFile("/home/user/file2.txt"),
|
||||
)
|
||||
|
||||
state.Succeed(t, "rm", "/home/user/file1.txt").RequireFiles(t,
|
||||
state.Fail(t, "rm", "/home/user/file1.txt").RequireFiles(t,
|
||||
ultest.File{Loc: "sj://user/file1.txt"},
|
||||
ultest.File{Loc: "sj://user/file2.txt"},
|
||||
ultest.File{Loc: "/home/user/file1.txt"},
|
||||
ultest.File{Loc: "/home/user/file2.txt"},
|
||||
)
|
||||
})
|
||||
@ -92,26 +93,12 @@ func TestRmLocal(t *testing.T) {
|
||||
ultest.WithFile("/home/user/other_file1.txt"),
|
||||
)
|
||||
|
||||
state.Succeed(t, "rm", "/home/user/files", "-r").RequireFiles(t,
|
||||
state.Fail(t, "rm", "/home/user/files", "-r").RequireFiles(t,
|
||||
ultest.File{Loc: "sj://user/files/file1.txt"},
|
||||
ultest.File{Loc: "sj://user/files/file2.txt"},
|
||||
ultest.File{Loc: "/home/user/files/file1.txt"},
|
||||
ultest.File{Loc: "/home/user/files/file2.txt"},
|
||||
ultest.File{Loc: "/home/user/other_file1.txt"},
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Pending", func(t *testing.T) {
|
||||
state := ultest.Setup(commands,
|
||||
ultest.WithFile("sj://user/file1.txt"),
|
||||
ultest.WithFile("sj://user/file2.txt"),
|
||||
ultest.WithFile("/home/user/file1.txt"),
|
||||
ultest.WithFile("/home/user/file2.txt"),
|
||||
)
|
||||
|
||||
state.Succeed(t, "rm", "/home/user/file1.txt", "--pending").RequireFiles(t,
|
||||
ultest.File{Loc: "sj://user/file1.txt"},
|
||||
ultest.File{Loc: "sj://user/file2.txt"},
|
||||
ultest.File{Loc: "/home/user/file1.txt"},
|
||||
ultest.File{Loc: "/home/user/file2.txt"},
|
||||
)
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user