Skip to content

Commit da91f16

Browse files
committed
feat: update
Signed-off-by: Gaius <gaius.qi@gmail.com>
1 parent 58045b8 commit da91f16

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

manager/job/preheat.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,12 @@ func (p *preheat) CreatePreheat(ctx context.Context, schedulers []models.Schedul
124124
return nil, err
125125
}
126126
case PreheatFileType:
127-
// File preheat supports to preheat multiple files and single file.
128-
if json.URL == "" && len(json.URLs) == 0 {
127+
urls := json.URLs
128+
if json.URL != "" {
129+
urls = append(urls, json.URL)
130+
}
131+
132+
if len(urls) == 0 {
129133
return nil, errors.New("invalid params: url or urls is required")
130134
}
131135

@@ -135,7 +139,7 @@ func (p *preheat) CreatePreheat(ctx context.Context, schedulers []models.Schedul
135139
}
136140

137141
files = append(files, internaljob.PreheatRequest{
138-
URLs: append(json.URLs, json.URL),
142+
URLs: urls,
139143
PieceLength: json.PieceLength,
140144
Tag: json.Tag,
141145
Application: json.Application,

scheduler/job/job.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func (j *job) preheatV2SingleSeedPeer(ctx context.Context, req *internaljob.Preh
296296
eg, _ := errgroup.WithContext(ctx)
297297
eg.SetLimit(int(req.ConcurrentCount))
298298

299-
var preheatResp *internaljob.PreheatResponse
299+
preheatResp := &internaljob.PreheatResponse{}
300300
for _, url := range req.URLs {
301301
eg.Go(func() error {
302302
resp, err := j.preheatV2SingleSeedPeerByURL(ctx, url, req, log)

test/e2e/manager/task.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var _ = Describe("GetTask and DeleteTask with Manager", func() {
5757
Type: internaljob.PreheatJob,
5858
Args: types.PreheatArgs{
5959
Type: "file",
60-
URL: testFile.GetDownloadURL(),
60+
URLs: []string{testFile.GetDownloadURL()},
6161
},
6262
SchedulerClusterIDs: []uint{1},
6363
})
@@ -163,7 +163,7 @@ var _ = Describe("GetTask and DeleteTask with Manager", func() {
163163
Type: internaljob.PreheatJob,
164164
Args: types.PreheatArgs{
165165
Type: "file",
166-
URL: testFile.GetDownloadURL(),
166+
URLs: []string{testFile.GetDownloadURL()},
167167
},
168168
SchedulerClusterIDs: []uint{1},
169169
})

0 commit comments

Comments
 (0)