Skip to content

Commit

Permalink
Use cleanup-cache flag (#717)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipta Das authored and tamalsaha committed Apr 3, 2019
1 parent f2669f1 commit bf91db4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/cli/restic.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func (w *ResticWrapper) Backup(resource *api.Restic, fg api.FileGroup) error {
args = append(args, tag)
}
args = w.appendCacheDirFlag(args)
args = w.appendCleanupCacheFlag(args)
args = w.appendCaCertFlag(args)

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

func (w *ResticWrapper) appendCleanupCacheFlag(args []interface{}) []interface{} {
if w.enableCache {
return append(args, "--cleanup-cache")
}
return args
}

func (w *ResticWrapper) appendCaCertFlag(args []interface{}) []interface{} {
if w.cacertFile != "" {
return append(args, "--cacert", w.cacertFile)
Expand Down
9 changes: 9 additions & 0 deletions pkg/restic/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func (w *ResticWrapper) backup(path, host string, tags []string) ([]byte, error)
args = append(args, tag)
}
args = w.appendCacheDirFlag(args)
args = w.appendCleanupCacheFlag(args)
args = w.appendCaCertFlag(args)

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

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

func (w *ResticWrapper) appendCleanupCacheFlag(args []interface{}) []interface{} {
if w.config.EnableCache {
return append(args, "--cleanup-cache")
}
return args
}

func (w *ResticWrapper) appendCaCertFlag(args []interface{}) []interface{} {
if w.config.CacertFile != "" {
return append(args, "--cacert", w.config.CacertFile)
Expand Down

0 comments on commit bf91db4

Please sign in to comment.