{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:
parent
94263174cf
commit
a4f91ae7cf
7 changed files with 298 additions and 91 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue