@@ -90,24 +90,25 @@ func (b *webDavStorage) Prune(deadline time.Time, pruningPrefix string) (*storag
9090 if err != nil {
9191 return nil , errwrap .Wrap (err , "error looking up candidates from remote storage" )
9292 }
93+
9394 var matches []fs.FileInfo
94- var lenCandidates int
95+ var numCandidates int
9596 for _ , candidate := range candidates {
96- if ! strings .HasPrefix (candidate .Name (), pruningPrefix ) {
97+ if candidate . IsDir () || ! strings .HasPrefix (candidate .Name (), pruningPrefix ) {
9798 continue
9899 }
99- lenCandidates ++
100+ numCandidates ++
100101 if candidate .ModTime ().Before (deadline ) {
101102 matches = append (matches , candidate )
102103 }
103104 }
104105
105106 stats := & storage.PruneStats {
106- Total : uint (lenCandidates ),
107+ Total : uint (numCandidates ),
107108 Pruned : uint (len (matches )),
108109 }
109110
110- pruneErr := b .DoPrune (b .Name (), len (matches ), lenCandidates , deadline , func () error {
111+ pruneErr := b .DoPrune (b .Name (), len (matches ), numCandidates , deadline , func () error {
111112 for _ , match := range matches {
112113 if err := b .client .Remove (path .Join (b .DestinationPath , match .Name ())); err != nil {
113114 return errwrap .Wrap (err , "error removing file" )
0 commit comments