Former-commit-id: 761f6a6e30
This commit is contained in:
Henrique Dias 2017-06-25 11:21:42 +01:00
parent 5ed0527092
commit 7ba14ada7b
1 changed files with 13 additions and 4 deletions

View File

@ -28,6 +28,8 @@ type FileManager struct {
// a trailing slash.
WebDavURL string
scopes map[string]*scope
// Users is a map with the different configurations for each user.
Users map[string]*User
@ -36,10 +38,16 @@ type FileManager struct {
AfterSave CommandFunc
}
type scope struct {
path string
fileSystem webdav.FileSystem
handler *webdav.Handler
}
// User contains the configuration for each user.
type User struct {
// scope is the physical path the user has access to.
scope string
scope *scope
// fileSystem is the virtual file system the user has access.
fileSystem webdav.FileSystem
@ -153,9 +161,10 @@ func (m *FileManager) SetWebDavURL(url string) {
}
}
func (u *User) SetScope(scope string) {
u.scope = strings.TrimSuffix(scope, "/")
u.fileSystem = webdav.Dir(u.scope)
// SetScope updates a user scope and its virtual file system.
func (m *FileManager) SetScope(scope string, user string) {
m.scope = strings.TrimSuffix(scope, "/")
m.fileSystem = webdav.Dir(m.scope)
}
// Allowed checks if the user has permission to access a directory/file.