Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tank
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
tank
Commits
8baee297
Commit
8baee297
authored
6 years ago
by
Christian Pointner
Browse files
Options
Downloads
Patches
Plain Diff
added function to retrieved attached uploader
parent
765787d4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/v1/api_uploads.go
+1
-1
1 addition, 1 deletion
api/v1/api_uploads.go
importer/job.go
+16
-2
16 additions, 2 deletions
importer/job.go
with
17 additions
and
3 deletions
api/v1/api_uploads.go
+
1
−
1
View file @
8baee297
...
...
@@ -51,7 +51,7 @@ func (api *API) UploadFileSimple() http.Handler {
return
}
done
,
err
:=
job
.
Attach
Source
(
uint64
(
r
.
ContentLength
),
r
.
Body
)
done
,
err
:=
job
.
Attach
Uploader
(
uint64
(
r
.
ContentLength
),
r
.
Body
)
if
err
!=
nil
{
sendError
(
w
,
err
)
return
...
...
This diff is collapsed.
Click to expand it.
importer/job.go
+
16
−
2
View file @
8baee297
...
...
@@ -154,7 +154,7 @@ func (job *Job) Start(ctx context.Context, timeout time.Duration) (err error) {
return
}
func
(
job
*
Job
)
Attach
Source
(
len
gth
uint64
,
r
io
.
Reader
)
(
<-
chan
*
JobSourceResult
,
error
)
{
func
(
job
*
Job
)
Attach
Uploader
(
len
uint64
,
r
io
.
Reader
)
(
<-
chan
*
JobSourceResult
,
error
)
{
if
state
:=
atomic
.
LoadUint32
((
*
uint32
)(
&
job
.
State
));
state
!=
uint32
(
JobRunning
)
{
return
nil
,
ErrImportNotRunning
}
...
...
@@ -166,12 +166,26 @@ func (job *Job) AttachSource(length uint64, r io.Reader) (<-chan *JobSourceResul
if
ok
:=
atomic
.
CompareAndSwapUint32
(
&
job
.
sourceSet
,
0
,
1
);
!
ok
{
return
nil
,
ErrSourceAlreadyAttached
}
src
:=
newJobSourceUpload
(
len
gth
,
r
)
src
:=
newJobSourceUpload
(
len
,
r
)
job
.
source
=
src
close
(
job
.
subC
.
sourceAttached
)
return
src
.
done
,
nil
}
func
(
job
*
Job
)
GetAttachedUploader
()
io
.
Reader
{
select
{
case
<-
job
.
subC
.
sourceAttached
:
default
:
return
nil
}
src
,
ok
:=
job
.
source
.
(
*
JobSourceUpload
)
if
!
ok
{
return
nil
}
return
src
.
r
}
func
(
job
*
Job
)
Cancel
()
{
oldState
:=
atomic
.
SwapUint32
((
*
uint32
)(
&
job
.
State
),
uint32
(
JobCanceled
))
// this next line is why we need to make sure JobCanceled is smaller than all the other states.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment