Skip to content

Commit a7f4b56

Browse files
xmlqiuzhiqian
authored andcommitted
fix: Adapt the maximum speed limit logic for incremental updates.
Bug: https://pms.uniontech.com/bug-view-338383.html
1 parent 4dbd273 commit a7f4b56

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

src/internal/system/apt/apt.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,13 @@ func createCommandLine(cmdType string, cmdArgs []string) *exec.Cmd {
8888
case system.BackupJobType:
8989
return exec.Command(system.DeepinImmutableCtlPath, "admin", "deploy", "--backup", "-j")
9090
case system.IncrementalDownloadJobType:
91-
return exec.Command(system.DeepinImmutableCtlPath, "upgrade", "--download-only", "--status-fd", "3")
91+
args := []string{"upgrade", "--download-only", "--status-fd", "3"}
92+
args = append(args, cmdArgs...)
93+
return exec.Command(system.DeepinImmutableCtlPath, args...)
9294
case system.IncrementalUpdateJobType:
93-
return exec.Command(system.DeepinImmutableCtlPath, "upgrade", "--status-fd", "3")
95+
args := []string{"upgrade", "--status-fd", "3"}
96+
args = append(args, cmdArgs...)
97+
return exec.Command(system.DeepinImmutableCtlPath, args...)
9498
case system.FixErrorJobType:
9599
var errType system.JobErrorType
96100
if len(cmdArgs) >= 1 {

src/internal/system/apt/proxy.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121
"github.com/linuxdeepin/lastore-daemon/src/internal/system"
2222
)
2323

24+
const aptLimitKey = "Acquire::http::Dl-Limit"
25+
2426
type APTSystem struct {
2527
CmdSet map[string]*system.Command
2628
Indicator system.Indicator
@@ -275,7 +277,12 @@ func (p *APTSystem) DownloadSource(jobId string, packages []string, environ map[
275277
*/
276278

277279
if p.IncrementalUpdate {
278-
c := newAPTCommand(p, jobId, system.IncrementalDownloadJobType, p.Indicator, append(packages, OptionToArgs(args)...))
280+
var cmdArgs []string
281+
speedLimit, ok := args[aptLimitKey]
282+
if ok {
283+
cmdArgs = append(cmdArgs, "--max-recv-speed", speedLimit)
284+
}
285+
c := newAPTCommand(p, jobId, system.IncrementalDownloadJobType, p.Indicator, cmdArgs)
279286
c.SetEnv(environ)
280287
return c.Start()
281288
}
@@ -323,7 +330,12 @@ func (p *APTSystem) DistUpgrade(jobId string, packages []string, environ map[str
323330

324331
if p.IncrementalUpdate {
325332
logger.Info("incremental update")
326-
c := newAPTCommand(p, jobId, system.IncrementalUpdateJobType, p.Indicator, append(packages, OptionToArgs(args)...))
333+
var cmdArgs []string
334+
speedLimit, ok := args[aptLimitKey]
335+
if ok {
336+
cmdArgs = append(cmdArgs, "--max-recv-speed", speedLimit)
337+
}
338+
c := newAPTCommand(p, jobId, system.IncrementalUpdateJobType, p.Indicator, cmdArgs)
327339
c.SetEnv(environ)
328340
return c.Start()
329341
}

0 commit comments

Comments
 (0)