sftpd stats: add file path for active upload/download

This commit is contained in:
Nicola Murino
2019-08-08 19:33:16 +02:00
parent 9f5722a894
commit 90607d4f86
4 changed files with 17 additions and 2 deletions

View File

@@ -110,3 +110,13 @@ func (u *User) GetHomeDir() string {
func (u *User) HasQuotaRestrictions() bool {
return u.QuotaFiles > 0 || u.QuotaSize > 0
}
// GetRelativePath returns the path for a file relative to the user's home dir.
// This is the path as seen by SFTP users
func (u *User) GetRelativePath(path string) string {
rel, err := filepath.Rel(u.GetHomeDir(), path)
if err != nil {
return ""
}
return "/" + filepath.ToSlash(rel)
}