mirror of
https://github.com/offen/docker-volume-backup.git
synced 2024-11-22 05:10:28 +01:00
Run hooks in order of severity
This commit is contained in:
parent
88c90a206c
commit
1f727f698f
@ -12,6 +12,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -661,6 +662,9 @@ func (s *script) pruneOldBackups() error {
|
||||
// given levels in the defined ordering. In case executing a hook returns an
|
||||
// error, the following hooks will still be run before the function returns.
|
||||
func (s *script) runHooks(err error, level hookLevel) error {
|
||||
sort.SliceStable(s.hooks, func(i, j int) bool {
|
||||
return s.hooks[i].level < s.hooks[j].level
|
||||
})
|
||||
var actionErrors []error
|
||||
for _, hook := range s.hooks {
|
||||
if hook.level > level {
|
||||
|
Loading…
Reference in New Issue
Block a user