mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-06 14:20:55 +03:00
eventmanager: allow to access the backup file
so it can be used in email and other actions Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -727,3 +727,19 @@ func PanicOnError(err error) {
|
||||
panic(fmt.Errorf("unexpected error: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
// GetAbsolutePath returns an absolute path using the current dir as base
|
||||
// if name defines a relative path
|
||||
func GetAbsolutePath(name string) (string, error) {
|
||||
if name == "" {
|
||||
return name, errors.New("input path cannot be empty")
|
||||
}
|
||||
if filepath.IsAbs(name) {
|
||||
return name, nil
|
||||
}
|
||||
curDir, err := os.Getwd()
|
||||
if err != nil {
|
||||
return name, err
|
||||
}
|
||||
return filepath.Join(curDir, name), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user