Skip to content

Commit

Permalink
Wrap calls to context.OpenDB() with exitWithError()
Browse files Browse the repository at this point in the history
  • Loading branch information
js-ojus committed Aug 3, 2015
1 parent 1e39050 commit dd56c06
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions cmd/drive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ func (cmd *indexCmd) Run(args []string) {
byId := *cmd.byId
byMatches := *cmd.matches
sources, context, path := preprocessArgsByToggle(args, byMatches || byId)
context.OpenDB()
exitWithError(context.OpenDB())
defer context.CloseDB()

options := &drive.Options{
Expand Down Expand Up @@ -495,7 +495,7 @@ func (cmd *pullCmd) Flags(fs *flag.FlagSet) *flag.FlagSet {

func (cmd *pullCmd) Run(args []string) {
sources, context, path := preprocessArgsByToggle(args, (*cmd.byId || *cmd.matches))
context.OpenDB()
exitWithError(context.OpenDB())
defer context.CloseDB()

excludes := drive.NonEmptyTrimmedStrings(strings.Split(*cmd.excludeOps, ",")...)
Expand Down Expand Up @@ -588,7 +588,7 @@ func (cmd *pushCmd) Run(args []string) {
cmd.pushMounted(args)
} else {
sources, context, path := preprocessArgs(args)
context.OpenDB()
exitWithError(context.OpenDB())
defer context.CloseDB()

options := cmd.createPushOptions()
Expand Down Expand Up @@ -622,7 +622,7 @@ func (cmd *touchCmd) Flags(fs *flag.FlagSet) *flag.FlagSet {

func (cmd *touchCmd) Run(args []string) {
sources, context, path := preprocessArgsByToggle(args, *cmd.matches || *cmd.byId)
context.OpenDB()
exitWithError(context.OpenDB())
defer context.CloseDB()

opts := drive.Options{
Expand Down Expand Up @@ -700,7 +700,7 @@ func (cmd *pushCmd) pushMounted(args []string) {

rest = drive.NonEmptyStrings(rest...)
context, path := discoverContext(contextArgs)
context.OpenDB()
exitWithError(context.OpenDB())
defer context.CloseDB()

contextAbsPath, err := filepath.Abs(path)
Expand Down Expand Up @@ -781,7 +781,7 @@ func (cmd *diffCmd) Flags(fs *flag.FlagSet) *flag.FlagSet {

func (cmd *diffCmd) Run(args []string) {
sources, context, path := preprocessArgs(args)
context.OpenDB()
exitWithError(context.OpenDB())
defer context.CloseDB()

exitWithError(drive.New(context, &drive.Options{
Expand Down Expand Up @@ -860,7 +860,7 @@ func (cmd *deleteCmd) Flags(fs *flag.FlagSet) *flag.FlagSet {

func (cmd *deleteCmd) Run(args []string) {
sources, context, path := preprocessArgsByToggle(args, *cmd.matches || *cmd.byId)
context.OpenDB()
exitWithError(context.OpenDB())
defer context.CloseDB()

opts := drive.Options{
Expand Down Expand Up @@ -893,7 +893,7 @@ func (cmd *trashCmd) Flags(fs *flag.FlagSet) *flag.FlagSet {

func (cmd *trashCmd) Run(args []string) {
sources, context, path := preprocessArgsByToggle(args, *cmd.matches || *cmd.byId)
context.OpenDB()
exitWithError(context.OpenDB())
defer context.CloseDB()

opts := drive.Options{
Expand Down Expand Up @@ -922,7 +922,7 @@ func (cmd *newCmd) Flags(fs *flag.FlagSet) *flag.FlagSet {

func (cmd *newCmd) Run(args []string) {
sources, context, path := preprocessArgs(args)
context.OpenDB()
exitWithError(context.OpenDB())
defer context.CloseDB()

opts := drive.Options{
Expand Down Expand Up @@ -969,7 +969,7 @@ func (cmd *copyCmd) Run(args []string) {
dest := args[end]

sources, context, path := preprocessArgsByToggle(args, *cmd.byId)
context.OpenDB()
exitWithError(context.OpenDB())
defer context.CloseDB()

// Unshift by the end path
Expand Down Expand Up @@ -1005,7 +1005,7 @@ func (cmd *untrashCmd) Flags(fs *flag.FlagSet) *flag.FlagSet {

func (cmd *untrashCmd) Run(args []string) {
sources, context, path := preprocessArgsByToggle(args, *cmd.byId || *cmd.matches)
context.OpenDB()
exitWithError(context.OpenDB())
defer context.CloseDB()

opts := drive.Options{
Expand Down Expand Up @@ -1085,7 +1085,7 @@ func (cmd *moveCmd) Run(args []string) {
exitWithError(fmt.Errorf("move: expecting a path or more"))
}
sources, context, path := preprocessArgsByToggle(args, *cmd.byId)
context.OpenDB()
exitWithError(context.OpenDB())
defer context.CloseDB()

// Unshift by the end path
Expand Down Expand Up @@ -1124,7 +1124,7 @@ func (cmd *renameCmd) Run(args []string) {
}
rest, last := args[:argc-1], args[argc-1]
sources, context, path := preprocessArgsByToggle(rest, *cmd.byId)
context.OpenDB()
exitWithError(context.OpenDB())
defer context.CloseDB()

sources = append(sources, last)
Expand Down

0 comments on commit dd56c06

Please sign in to comment.