mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-07 05:42:42 +00:00
Major refactoring to lower memory consumption.
Package has been split into multiple structure loaded on demand: files, extra, depends. They're saved and loaded completely separately.
This commit is contained in:
Vendored
+9
-32
@@ -363,54 +363,31 @@ func (repo *RemoteRepo) Download(progress aptly.Progress, d aptly.Downloader, pa
|
||||
return err
|
||||
}
|
||||
}
|
||||
list.Add(p)
|
||||
}
|
||||
}
|
||||
|
||||
progress.Printf("Saving packages to database...\n")
|
||||
|
||||
progress.InitBar(int64(list.Len()), false)
|
||||
|
||||
packageCollection.db.StartBatch()
|
||||
count := 0
|
||||
|
||||
// Save package meta information to DB
|
||||
err := list.ForEach(func(p *Package) error {
|
||||
progress.AddBar(1)
|
||||
count++
|
||||
if count > 1000 {
|
||||
count = 0
|
||||
err := packageCollection.db.FinishBatch()
|
||||
err = list.Add(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = packageCollection.Update(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
packageCollection.db.StartBatch()
|
||||
}
|
||||
return packageCollection.Update(p)
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to save packages to db: %s", err)
|
||||
}
|
||||
|
||||
err = packageCollection.db.FinishBatch()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to save packages to db: %s", err)
|
||||
}
|
||||
|
||||
progress.ShutdownBar()
|
||||
|
||||
progress.Printf("Building download queue...\n")
|
||||
|
||||
// Build download queue
|
||||
queued := make(map[string]PackageDownloadTask, list.Len())
|
||||
count = 0
|
||||
count := 0
|
||||
downloadSize := int64(0)
|
||||
|
||||
err = list.ForEach(func(p *Package) error {
|
||||
err := list.ForEach(func(p *Package) error {
|
||||
list, err := p.DownloadList(packagePool)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.files = nil
|
||||
|
||||
for _, task := range list {
|
||||
key := task.RepoURI + "-" + task.DestinationPath
|
||||
|
||||
Reference in New Issue
Block a user