add docs for virtual folders
fix test cases on macOS
This commit is contained in:
parent
8306b6bde6
commit
c231b663a3
3 changed files with 35 additions and 5 deletions
31
docs/virtual-folders.md
Normal file
31
docs/virtual-folders.md
Normal file
|
@ -0,0 +1,31 @@
|
|||
# Virtual Folders
|
||||
|
||||
A virtual folder is a mapping between a SFTP/SCP virtual path and a filesystem path outside the user home directory.
|
||||
The specified paths must be absolute and the virtual path cannot be "/", it must be a sub directory.
|
||||
The parent directory to the specified virtual path must exist. SFTPGo will try to automatically create any missing parent directory for the configured virtual folders at user login.
|
||||
|
||||
For each virtual folder, the following properties can be configured:
|
||||
|
||||
- `mapped_path`, the full absolute path to the filesystem path to expose as virtual folder
|
||||
- `virtual_path`, the SFTP/SCP absolute path to use to expose the mapped path
|
||||
- `quota_size`, maximum size allowed as bytes. 0 means unlimited, -1 included in user quota
|
||||
- `quota_files`, maximum number of files allowed. 0 means unlimited, -1 included in user quota
|
||||
|
||||
For example if you configure `/tmp/mapped` or `C:\mapped` as mapped path and `/vfolder` as virtual path then SFTP/SCP users can access the mapped path via the `/vfolder` SFTP path.
|
||||
|
||||
The same virtual folder, identified by the `mapped_path`, can be shared among users and different folder quota limits for each user are supported.
|
||||
Folder quota limits can also be included inside the user quota but in this case the folder is considered "private" and sharing it with other users will break user quota calculation.
|
||||
|
||||
You don't need to create virtual folders, inside the data provider, to associate them to the users: any missing virtual folder will be automatically created when you add/update an user. You have to create the folder on the filesystem yourself.
|
||||
|
||||
Using the REST API you can:
|
||||
|
||||
- monitor folder quota usage
|
||||
- scan quota for a virtual folder
|
||||
- inspect the users associated with a virtual folder
|
||||
- delete a virtual folder. SFTPGo remove folders from the data provider, no deletion will occur on the filesystem
|
||||
|
||||
If you remove a folder, from the data provider, any users relationship will be cleaned up. If the deleted folder is included inside the user quota you need to do a user quota scan to update its quota. An orphan virtual folder will not be automatically deleted since if you add it again later then a quota scan is needed and it could be quite expensive, anyway you can easily list the orphan virtual folders via REST API and delete them if they are not needed anymore.
|
||||
|
||||
Overlapping virtual or mapped paths are not allowed for the same user.
|
||||
Virtual folders are supported for local filesystem only.
|
|
@ -1107,7 +1107,7 @@ func TestQuotaTrackingDisabled(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
// folder quota scan must fail
|
||||
folder := vfs.BaseVirtualFolder{
|
||||
MappedPath: os.TempDir(),
|
||||
MappedPath: filepath.Clean(os.TempDir()),
|
||||
}
|
||||
folder, _, err = httpd.AddFolder(folder, http.StatusOK)
|
||||
assert.NoError(t, err)
|
||||
|
@ -1189,7 +1189,7 @@ func TestFolders(t *testing.T) {
|
|||
}
|
||||
_, _, err := httpd.AddFolder(folder, http.StatusBadRequest)
|
||||
assert.NoError(t, err)
|
||||
folder.MappedPath = os.TempDir()
|
||||
folder.MappedPath = filepath.Clean(os.TempDir())
|
||||
folder1, _, err := httpd.AddFolder(folder, http.StatusOK)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, folder.MappedPath, folder1.MappedPath)
|
||||
|
@ -2429,7 +2429,7 @@ func TestWebUserGCSMock(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAddWebFoldersMock(t *testing.T) {
|
||||
mappedPath := os.TempDir()
|
||||
mappedPath := filepath.Clean(os.TempDir())
|
||||
form := make(url.Values)
|
||||
form.Set("mapped_path", mappedPath)
|
||||
req, err := http.NewRequest(http.MethodPost, webFolderPath, strings.NewReader(form.Encode()))
|
||||
|
|
|
@ -6334,8 +6334,7 @@ func getExtAuthScriptContent(user dataprovider.User, nonJSONResponse bool) []byt
|
|||
extAuthContent = append(extAuthContent, []byte("echo 'text response'\n")...)
|
||||
} else {
|
||||
json, _ := json.Marshal(user)
|
||||
quoteJson := strconv.Quote(string(json))
|
||||
extAuthContent = append(extAuthContent, []byte(fmt.Sprintf("echo '%v'\n", quoteJson))...)
|
||||
extAuthContent = append(extAuthContent, []byte(fmt.Sprintf("echo '%v'\n", strconv.Quote(string(json))))...)
|
||||
}
|
||||
extAuthContent = append(extAuthContent, []byte("fi\n")...)
|
||||
return extAuthContent
|
||||
|
|
Loading…
Add table
Reference in a new issue