mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 21:05:10 +00:00
Merge pull request #4110 from MichaelEischer/remove-exitf
Remove Exitf function
This commit is contained in:
commit
0de3b24756
@ -141,7 +141,7 @@ func runDump(ctx context.Context, opts DumpOptions, gopts GlobalOptions, args []
|
|||||||
|
|
||||||
sn, err := restic.FindFilteredSnapshot(ctx, repo.Backend(), repo, opts.Paths, opts.Tags, opts.Hosts, nil, snapshotIDString)
|
sn, err := restic.FindFilteredSnapshot(ctx, repo.Backend(), repo, opts.Paths, opts.Tags, opts.Hosts, nil, snapshotIDString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Exitf(1, "failed to find snapshot: %v", err)
|
return errors.Fatalf("failed to find snapshot: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.LoadIndex(ctx)
|
err = repo.LoadIndex(ctx)
|
||||||
@ -151,13 +151,13 @@ func runDump(ctx context.Context, opts DumpOptions, gopts GlobalOptions, args []
|
|||||||
|
|
||||||
tree, err := restic.LoadTree(ctx, repo, *sn.Tree)
|
tree, err := restic.LoadTree(ctx, repo, *sn.Tree)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Exitf(2, "loading tree for snapshot %q failed: %v", snapshotIDString, err)
|
return errors.Fatalf("loading tree for snapshot %q failed: %v", snapshotIDString, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
d := dump.New(opts.Archive, repo, os.Stdout)
|
d := dump.New(opts.Archive, repo, os.Stdout)
|
||||||
err = printFromTree(ctx, tree, repo, "/", splittedPath, d)
|
err = printFromTree(ctx, tree, repo, "/", splittedPath, d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Exitf(2, "cannot dump file: %v", err)
|
return errors.Fatalf("cannot dump file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -133,7 +133,7 @@ func runRestore(ctx context.Context, opts RestoreOptions, gopts GlobalOptions, a
|
|||||||
|
|
||||||
sn, err := restic.FindFilteredSnapshot(ctx, repo.Backend(), repo, opts.Hosts, opts.Tags, opts.Paths, nil, snapshotIDString)
|
sn, err := restic.FindFilteredSnapshot(ctx, repo.Backend(), repo, opts.Hosts, opts.Tags, opts.Paths, nil, snapshotIDString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Exitf(1, "failed to find snapshot: %v", err)
|
return errors.Fatalf("failed to find snapshot: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo.LoadIndex(ctx)
|
err = repo.LoadIndex(ctx)
|
||||||
|
@ -281,17 +281,6 @@ func Warnf(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exitf uses Warnf to write the message and then terminates the process with
|
|
||||||
// the given exit code.
|
|
||||||
func Exitf(exitcode int, format string, args ...interface{}) {
|
|
||||||
if !(strings.HasSuffix(format, "\n")) {
|
|
||||||
format += "\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
Warnf(format, args...)
|
|
||||||
Exit(exitcode)
|
|
||||||
}
|
|
||||||
|
|
||||||
// resolvePassword determines the password to be used for opening the repository.
|
// resolvePassword determines the password to be used for opening the repository.
|
||||||
func resolvePassword(opts GlobalOptions, envStr string) (string, error) {
|
func resolvePassword(opts GlobalOptions, envStr string) (string, error) {
|
||||||
if opts.PasswordFile != "" && opts.PasswordCommand != "" {
|
if opts.PasswordFile != "" && opts.PasswordCommand != "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user