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