Skip to content

Commit

Permalink
Disable the service when the repoList is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
vHanda committed May 13, 2022
1 parent f1f22c5 commit a7fdb32
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 6 additions & 3 deletions common/service.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package common

import (
"fmt"
"log"
"os"
"os/user"
Expand Down Expand Up @@ -74,7 +73,6 @@ func (srv Service) Enable() error {
// Also stop the old service?

err := srv.Service.Install()
fmt.Println("Installed")
if err != nil {
if strings.Contains(err.Error(), "Init already exists") {
return nil
Expand All @@ -91,7 +89,12 @@ func (srv Service) Enable() error {
}

func (srv Service) Disable() error {
err := srv.Service.Uninstall()
err := srv.Service.Stop()
if err != nil {
return tracerr.Wrap(err)
}

err = srv.Service.Uninstall()
if err != nil {
return tracerr.Wrap(err)
}
Expand Down
12 changes: 11 additions & 1 deletion daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,17 @@ func daemonRm(ctx *cli.Context) error {
return tracerr.Wrap(err)
}

// TODO: Disable if it is running and Repos is empty
if len(config.Repos) == 0 {
s, err := common.NewService()
if err != nil {
return tracerr.Wrap(err)
}

err = s.Disable()
if err != nil {
return tracerr.Wrap(err)
}
}

return nil
}
Expand Down

0 comments on commit a7fdb32

Please sign in to comment.