mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-08 07:10:56 +03:00
Cloud FS: don't propagate the error if removing a folder returns not found
for Cloud FS the folders are virtual and they, generally, disappear when the last file is removed. This fix doesn't work for FTP protocol for now. Fixes #149
This commit is contained in:
@@ -16,6 +16,29 @@ import (
|
||||
"github.com/drakkan/sftpgo/vfs"
|
||||
)
|
||||
|
||||
// MockOsFs mockable OsFs
|
||||
type MockOsFs struct {
|
||||
vfs.Fs
|
||||
hasVirtualFolders bool
|
||||
}
|
||||
|
||||
// Name returns the name for the Fs implementation
|
||||
func (fs MockOsFs) Name() string {
|
||||
return "mockOsFs"
|
||||
}
|
||||
|
||||
// HasVirtualFolders returns true if folders are emulated
|
||||
func (fs MockOsFs) HasVirtualFolders() bool {
|
||||
return fs.hasVirtualFolders
|
||||
}
|
||||
|
||||
func newMockOsFs(hasVirtualFolders bool, connectionID, rootDir string) vfs.Fs {
|
||||
return &MockOsFs{
|
||||
Fs: vfs.NewOsFs(connectionID, rootDir, nil),
|
||||
hasVirtualFolders: hasVirtualFolders,
|
||||
}
|
||||
}
|
||||
|
||||
func TestListDir(t *testing.T) {
|
||||
user := dataprovider.User{
|
||||
Username: userTestUsername,
|
||||
@@ -213,6 +236,14 @@ func TestRemoveDir(t *testing.T) {
|
||||
err = c.RemoveDir(testDir, "/testDir")
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = c.RemoveDir(testDir, "/testDir")
|
||||
assert.Error(t, err)
|
||||
|
||||
fs = newMockOsFs(true, "", user.GetHomeDir())
|
||||
c.Fs = fs
|
||||
err = c.RemoveDir(testDir, "/testDir")
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = os.RemoveAll(mappedPath)
|
||||
assert.NoError(t, err)
|
||||
err = os.RemoveAll(user.GetHomeDir())
|
||||
|
||||
Reference in New Issue
Block a user