Skip to content

Commit bf91db4

Browse files
Dipta Dastamalsaha
authored andcommitted
Use cleanup-cache flag (#717)
1 parent f2669f1 commit bf91db4

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

pkg/cli/restic.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ func (w *ResticWrapper) Backup(resource *api.Restic, fg api.FileGroup) error {
9494
args = append(args, tag)
9595
}
9696
args = w.appendCacheDirFlag(args)
97+
args = w.appendCleanupCacheFlag(args)
9798
args = w.appendCaCertFlag(args)
9899

99100
return w.run(Exe, args)
@@ -191,6 +192,13 @@ func (w *ResticWrapper) appendCacheDirFlag(args []interface{}) []interface{} {
191192
return append(args, "--no-cache")
192193
}
193194

195+
func (w *ResticWrapper) appendCleanupCacheFlag(args []interface{}) []interface{} {
196+
if w.enableCache {
197+
return append(args, "--cleanup-cache")
198+
}
199+
return args
200+
}
201+
194202
func (w *ResticWrapper) appendCaCertFlag(args []interface{}) []interface{} {
195203
if w.cacertFile != "" {
196204
return append(args, "--cacert", w.cacertFile)

pkg/restic/commands.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func (w *ResticWrapper) backup(path, host string, tags []string) ([]byte, error)
8282
args = append(args, tag)
8383
}
8484
args = w.appendCacheDirFlag(args)
85+
args = w.appendCleanupCacheFlag(args)
8586
args = w.appendCaCertFlag(args)
8687

8788
return w.run(Command{Name: ResticCMD, Args: args})
@@ -106,6 +107,7 @@ func (w *ResticWrapper) backupFromStdin(options BackupOptions) ([]byte, error) {
106107
args = append(args, options.Host)
107108
}
108109
args = w.appendCacheDirFlag(args)
110+
args = w.appendCleanupCacheFlag(args)
109111
args = w.appendCaCertFlag(args)
110112

111113
commands = append(commands, Command{Name: ResticCMD, Args: args})
@@ -247,6 +249,13 @@ func (w *ResticWrapper) appendCacheDirFlag(args []interface{}) []interface{} {
247249
return append(args, "--no-cache")
248250
}
249251

252+
func (w *ResticWrapper) appendCleanupCacheFlag(args []interface{}) []interface{} {
253+
if w.config.EnableCache {
254+
return append(args, "--cleanup-cache")
255+
}
256+
return args
257+
}
258+
250259
func (w *ResticWrapper) appendCaCertFlag(args []interface{}) []interface{} {
251260
if w.config.CacertFile != "" {
252261
return append(args, "--cacert", w.config.CacertFile)

0 commit comments

Comments
 (0)