Skip to content

[breaking] daemon: Fix concurrency and streamline access to PackageManager #1828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Aug 26, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Made CoreInstance.PackageManager field private
  • Loading branch information
cmaglie committed Aug 23, 2022
commit dd0414f7265b0eee1b7db8e334a22069e6eb9289
16 changes: 8 additions & 8 deletions commands/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ var tr = i18n.Tr
// instantiate as many as needed by providing a different configuration
// for each one.
type CoreInstance struct {
PackageManager *packagemanager.PackageManager
lm *librariesmanager.LibrariesManager
pm *packagemanager.PackageManager
lm *librariesmanager.LibrariesManager
}

// coreInstancesContainer has methods to add an remove instances atomically.
Expand Down Expand Up @@ -106,7 +106,7 @@ func GetPackageManager(id int32) *packagemanager.PackageManager {
if i == nil {
return nil
}
return i.PackageManager
return i.pm
}

// GetPackageManagerExplorer returns a new package manager Explorer. The
Expand Down Expand Up @@ -134,11 +134,11 @@ func (instance *CoreInstance) installToolIfMissing(tool *cores.ToolRelease, down
return false, nil
}
taskCB(&rpc.TaskProgress{Name: tr("Downloading missing tool %s", tool)})
if err := instance.PackageManager.DownloadToolRelease(tool, nil, downloadCB); err != nil {
if err := instance.pm.DownloadToolRelease(tool, nil, downloadCB); err != nil {
return false, fmt.Errorf(tr("downloading %[1]s tool: %[2]s"), tool, err)
}
taskCB(&rpc.TaskProgress{Completed: true})
if err := instance.PackageManager.InstallTool(tool, taskCB); err != nil {
if err := instance.pm.InstallTool(tool, taskCB); err != nil {
return false, fmt.Errorf(tr("installing %[1]s tool: %[2]s"), tool, err)
}
return true, nil
Expand Down Expand Up @@ -172,7 +172,7 @@ func Create(req *rpc.CreateRequest, extraUserAgent ...string) (*rpc.CreateRespon
for _, ua := range extraUserAgent {
userAgent += " " + ua
}
instance.PackageManager = packagemanager.NewBuilder(
instance.pm = packagemanager.NewBuilder(
dataDir,
configuration.PackagesDir(configuration.Settings),
downloadsDir,
Expand Down Expand Up @@ -268,7 +268,7 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
// after reinitializing an instance after installing or uninstalling a core.
// If this is not done the information of the uninstall core is kept in memory,
// even if it should not.
pmb, commitPackageManager := instance.PackageManager.NewBuilder()
pmb, commitPackageManager := instance.pm.NewBuilder()

loadBuiltinTools := func() []error {
builtinPackage := pmb.GetOrCreatePackage("builtin")
Expand Down Expand Up @@ -362,7 +362,7 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
commitPackageManager()
}

pme, release := instance.PackageManager.NewExplorer()
pme, release := instance.pm.NewExplorer()
defer release()

for _, err := range pme.LoadDiscoveries() {
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy