{backup,snapshort}: Improve behaviour

This commit improves the behaviour of 'backup' and 'snapshot' by
treating symbolic links properly, as well as writes proper reports.
This commit is contained in:
Tom Wiesing 2022-09-13 11:44:32 +02:00
parent 94263174cf
commit a4f91ae7cf
No known key found for this signature in database
7 changed files with 298 additions and 91 deletions

View file

@ -7,7 +7,7 @@ import (
// Exists checks if the given path exists
func Exists(path string) bool {
_, err := os.Stat(path)
_, err := os.Lstat(path)
return err == nil
}
@ -22,3 +22,9 @@ func IsFile(path string) bool {
info, err := os.Stat(path)
return err == nil && info.Mode().IsRegular()
}
// IsLink checks if the provided path exists and is a symlink
func IsLink(path string) bool {
info, err := os.Lstat(path)
return err == nil && info.Mode()&os.ModeSymlink != 0
}