Fixes for refactoring to cmd.

This commit is contained in:
Andrey Smirnov
2014-02-19 15:07:41 +04:00
parent eb18b04c40
commit ccff7935bd
3 changed files with 30 additions and 93 deletions
-1
View File
@@ -36,7 +36,6 @@ func RootCommand() *commander.Command {
UsageLine: os.Args[0],
Short: "Debian repository management tool",
Long: `
}
aptly is a tool to create partial and full mirrors of remote
repositories, filter them, merge, upgrade individual packages,
take snapshots and publish them back as Debian repositories.`,
+8 -3
View File
@@ -25,6 +25,7 @@ var context struct {
architecturesList []string
}
// InitContext initializes context with default settings
func InitContext(cmd *commander.Command) error {
var err error
@@ -50,19 +51,23 @@ func InitContext(cmd *commander.Command) error {
context.progress = console.NewProgress()
context.progress.Start()
defer context.progress.Shutdown()
context.downloader = http.NewDownloader(utils.Config.DownloadConcurrency, context.progress)
defer context.downloader.Shutdown()
context.database, err = database.OpenDB(filepath.Join(utils.Config.RootDir, "db"))
if err != nil {
return fmt.Errorf("can't open database: %s", err)
}
defer context.database.Close()
context.packagePool = files.NewPackagePool(utils.Config.RootDir)
context.publishedStorage = files.NewPublishedStorage(utils.Config.RootDir)
return nil
}
// ShutdownContext shuts context down
func ShutdownContext() {
context.database.Close()
context.downloader.Shutdown()
context.progress.Shutdown()
}