File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -162,10 +162,7 @@ func (opt *keyOptions) addResticKey() error {
162162 if err = os .MkdirAll (ScratchDir , 0o755 ); err != nil {
163163 return err
164164 }
165- err = os .RemoveAll (ScratchDir )
166- if err != nil {
167- klog .Errorf ("Error removing all: %v" , err )
168- }
165+ RemoveDirWithLogErr (ScratchDir )
169166 // configure restic wrapper
170167 extraOpt := util.ExtraOptions {
171168 StorageSecret : secret ,
Original file line number Diff line number Diff line change @@ -132,10 +132,7 @@ func (opt *checkOptions) checkRepository(extraArgs []string) error {
132132 if err = os .MkdirAll (ScratchDir , 0o755 ); err != nil {
133133 return err
134134 }
135- err = os .RemoveAll (ScratchDir )
136- if err != nil {
137- klog .Errorf ("Error removing all: %v" , err )
138- }
135+ RemoveDirWithLogErr (ScratchDir )
139136
140137 // configure restic wrapper
141138 extraOpt := util.ExtraOptions {
Original file line number Diff line number Diff line change @@ -106,10 +106,7 @@ func NewCmdDeleteSnapshot(clientGetter genericclioptions.RESTClientGetter) *cobr
106106 if err = os .MkdirAll (ScratchDir , 0o755 ); err != nil {
107107 return err
108108 }
109- err = os .RemoveAll (ScratchDir )
110- if err != nil {
111- klog .Errorf ("Error removing all: %v" , err )
112- }
109+ RemoveDirWithLogErr (ScratchDir )
113110
114111 // configure restic wrapper
115112 extraOpt := util.ExtraOptions {
Original file line number Diff line number Diff line change @@ -171,10 +171,7 @@ func (opt *downloadOptions) downloadSnapshots() error {
171171 if err = os .MkdirAll (ScratchDir , 0o755 ); err != nil {
172172 return err
173173 }
174- err = os .RemoveAll (ScratchDir )
175- if err != nil {
176- klog .Errorf ("Error removing all: %v" , err )
177- }
174+ RemoveDirWithLogErr (ScratchDir )
178175
179176 // configure restic wrapper
180177 extraOpt := util.ExtraOptions {
Original file line number Diff line number Diff line change @@ -97,10 +97,7 @@ func (opt *keyOptions) listResticKeys() error {
9797 if err = os .MkdirAll (ScratchDir , 0o755 ); err != nil {
9898 return err
9999 }
100- err = os .RemoveAll (ScratchDir )
101- if err != nil {
102- klog .Errorf ("Error removing all: %v" , err )
103- }
100+ RemoveDirWithLogErr (ScratchDir )
104101
105102 // configure restic wrapper
106103 extraOpt := util.ExtraOptions {
Original file line number Diff line number Diff line change @@ -130,10 +130,7 @@ func (opt *migrateOptions) migrateRepo() error {
130130 if err = os .MkdirAll (ScratchDir , 0o755 ); err != nil {
131131 return err
132132 }
133- err = os .RemoveAll (ScratchDir )
134- if err != nil {
135- klog .Errorf ("Error removing all: %v" , err )
136- }
133+ RemoveDirWithLogErr (ScratchDir )
137134
138135 // configure restic wrapper
139136 extraOpt := util.ExtraOptions {
Original file line number Diff line number Diff line change @@ -146,10 +146,7 @@ func (opt *pruneOptions) pruneRepo(extraArgs []string) error {
146146 if err = os .MkdirAll (ScratchDir , 0o755 ); err != nil {
147147 return err
148148 }
149- err = os .RemoveAll (ScratchDir )
150- if err != nil {
151- klog .Errorf ("Error removing all: %v" , err )
152- }
149+ RemoveDirWithLogErr (ScratchDir )
153150
154151 // configure restic wrapper
155152 extraOpt := util.ExtraOptions {
Original file line number Diff line number Diff line change @@ -278,9 +278,7 @@ func (opt *purgeOptions) setupScratchDirectory() error {
278278}
279279
280280func (opt * purgeOptions ) cleanupScratchDirectory () {
281- if err := os .RemoveAll (ScratchDir ); err != nil {
282- klog .Warningf ("Failed to cleanup scratch directory: %v" , err )
283- }
281+ RemoveDirWithLogErr (ScratchDir )
284282}
285283
286284func (opt * purgeOptions ) getStorageSecret () (* core.Secret , error ) {
Original file line number Diff line number Diff line change @@ -106,10 +106,7 @@ func (opt *rebuildIndexOptions) rebuildIndex(extraArgs []string) error {
106106 if err = os .MkdirAll (ScratchDir , 0o755 ); err != nil {
107107 return err
108108 }
109- err = os .RemoveAll (ScratchDir )
110- if err != nil {
111- klog .Errorf ("Error removing all: %v" , err )
112- }
109+ RemoveDirWithLogErr (ScratchDir )
113110
114111 // configure restic wrapper
115112 extraOpt := util.ExtraOptions {
Original file line number Diff line number Diff line change @@ -93,10 +93,8 @@ func (opt *keyOptions) removeResticKey() error {
9393 if err = os .MkdirAll (ScratchDir , 0o755 ); err != nil {
9494 return err
9595 }
96- err = os .RemoveAll (ScratchDir )
97- if err != nil {
98- klog .Errorf ("Error removing all: %v" , err )
99- }
96+
97+ RemoveDirWithLogErr (ScratchDir )
10098
10199 // configure restic wrapper
102100 extraOpt := util.ExtraOptions {
You can’t perform that action at this time.
0 commit comments