mirror of
https://github.com/restic/restic.git
synced 2026-09-28 23:10:31 +00:00
Remove ctx from globalOptions
Previously the global context was either accessed via gopts.ctx, stored in a local variable and then used within that function or sometimes both. This makes it very hard to follow which ctx or a wrapped version of it reaches which method. Thus just drop the context from the globalOptions struct and pass it explicitly to every command line handler method.
This commit is contained in:
@@ -35,7 +35,7 @@ Exit status is 0 if the command was successful, and non-zero if there was any er
|
||||
`,
|
||||
DisableAutoGenTag: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runDiff(diffOptions, globalOptions, args)
|
||||
return runDiff(globalCtx(), diffOptions, globalOptions, args)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -321,13 +321,12 @@ func (c *Comparer) diffTree(ctx context.Context, stats *DiffStatsContainer, pref
|
||||
return nil
|
||||
}
|
||||
|
||||
func runDiff(opts DiffOptions, gopts GlobalOptions, args []string) error {
|
||||
func runDiff(ctx context.Context, opts DiffOptions, gopts GlobalOptions, args []string) error {
|
||||
if len(args) != 2 {
|
||||
return errors.Fatalf("specify two snapshot IDs")
|
||||
}
|
||||
|
||||
ctx := gopts.ctx
|
||||
repo, err := OpenRepository(gopts)
|
||||
repo, err := OpenRepository(ctx, gopts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user