eventmanager: add copy action

refactor sftpgo-copy and sftpgo-remove commands

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-12-27 18:51:53 +01:00
parent e5a8220b8a
commit ea4c4dd57f
28 changed files with 1208 additions and 658 deletions

View File

@@ -422,6 +422,26 @@ func GenerateEd25519Keys(file string) error {
return os.WriteFile(file+".pub", ssh.MarshalAuthorizedKey(pub), 0600)
}
// IsDirOverlapped returns true if dir1 and dir2 overlap
func IsDirOverlapped(dir1, dir2 string, fullCheck bool, separator string) bool {
if dir1 == dir2 {
return true
}
if fullCheck {
if len(dir1) > len(dir2) {
if strings.HasPrefix(dir1, dir2+separator) {
return true
}
}
if len(dir2) > len(dir1) {
if strings.HasPrefix(dir2, dir1+separator) {
return true
}
}
}
return false
}
// GetDirsForVirtualPath returns all the directory for the given path in reverse order
// for example if the path is: /1/2/3/4 it returns:
// [ "/1/2/3/4", "/1/2/3", "/1/2", "/1", "/" ]