Skip to content
Snippets Groups Projects
Commit 765787d4 authored by Christian Pointner's avatar Christian Pointner
Browse files

rename attachment to upload

parent 7182740d
No related branches found
No related tags found
No related merge requests found
...@@ -53,7 +53,7 @@ func (im *Importer) ListJobs(group string) (Jobs, error) { ...@@ -53,7 +53,7 @@ func (im *Importer) ListJobs(group string) (Jobs, error) {
func (im *Importer) CreateJob(group string, id uint64, src url.URL, user, refID string) (*Job, error) { func (im *Importer) CreateJob(group string, id uint64, src url.URL, user, refID string) (*Job, error) {
// TODO: update this list once we implemented other sources // TODO: update this list once we implemented other sources
switch src.Scheme { switch src.Scheme {
case SourceSchemeAttachment: case SourceSchemeUpload:
case SourceSchemeFake: case SourceSchemeFake:
default: default:
return nil, ErrSourceNotSupported return nil, ErrSourceNotSupported
......
...@@ -159,14 +159,14 @@ func (job *Job) AttachSource(length uint64, r io.Reader) (<-chan *JobSourceResul ...@@ -159,14 +159,14 @@ func (job *Job) AttachSource(length uint64, r io.Reader) (<-chan *JobSourceResul
return nil, ErrImportNotRunning return nil, ErrImportNotRunning
} }
// only allow to attach external sources if the job's source was in fact an attachment URL // only allow to attach external sources if the job's source was in fact an upload URL
if job.Source.Scheme != SourceSchemeAttachment { if job.Source.Scheme != SourceSchemeUpload {
return nil, ErrSourceAlreadyAttached return nil, ErrSourceAlreadyAttached
} }
if ok := atomic.CompareAndSwapUint32(&job.sourceSet, 0, 1); !ok { if ok := atomic.CompareAndSwapUint32(&job.sourceSet, 0, 1); !ok {
return nil, ErrSourceAlreadyAttached return nil, ErrSourceAlreadyAttached
} }
src := newJobSourceAttachment(length, r) src := newJobSourceUpload(length, r)
job.source = src job.source = src
close(job.subC.sourceAttached) close(job.subC.sourceAttached)
return src.done, nil return src.done, nil
......
...@@ -31,7 +31,7 @@ import ( ...@@ -31,7 +31,7 @@ import (
) )
func (job *Job) initializeSource() (err error) { func (job *Job) initializeSource() (err error) {
if job.Source.Scheme == SourceSchemeAttachment { if job.Source.Scheme == SourceSchemeUpload {
// the source will be attached using job.AttachSource() so all we need to do // the source will be attached using job.AttachSource() so all we need to do
// is to wait for it to happen // is to wait for it to happen
select { select {
...@@ -85,29 +85,29 @@ func (src *JobSourceFake) Done(result *JobSourceResult) { ...@@ -85,29 +85,29 @@ func (src *JobSourceFake) Done(result *JobSourceResult) {
return return
} }
//******* Attachment //******* Upload
type JobSourceAttachment struct { type JobSourceUpload struct {
len uint64 len uint64
r io.Reader r io.Reader
done chan *JobSourceResult done chan *JobSourceResult
} }
func newJobSourceAttachment(len uint64, r io.Reader) *JobSourceAttachment { func newJobSourceUpload(len uint64, r io.Reader) *JobSourceUpload {
src := &JobSourceAttachment{len: len, r: r} src := &JobSourceUpload{len: len, r: r}
src.done = make(chan *JobSourceResult, 1) src.done = make(chan *JobSourceResult, 1)
return src return src
} }
func (src *JobSourceAttachment) Len() uint64 { func (src *JobSourceUpload) Len() uint64 {
return src.len return src.len
} }
func (src *JobSourceAttachment) Read(p []byte) (n int, err error) { func (src *JobSourceUpload) Read(p []byte) (n int, err error) {
return src.r.Read(p) return src.r.Read(p)
} }
func (src *JobSourceAttachment) Done(result *JobSourceResult) { func (src *JobSourceUpload) Done(result *JobSourceResult) {
if result == nil { if result == nil {
close(src.done) close(src.done)
return return
......
...@@ -38,8 +38,8 @@ import ( ...@@ -38,8 +38,8 @@ import (
const ( const (
DefaultBacklog = 100 DefaultBacklog = 100
SourceSchemeAttachment = "attachment" SourceSchemeUpload = "upload"
SourceSchemeFake = "fake" SourceSchemeFake = "fake"
) )
//******* Errors //******* Errors
......
...@@ -46,8 +46,8 @@ var ( ...@@ -46,8 +46,8 @@ var (
testGroup2 = "test2" testGroup2 = "test2"
testUser1 = "user1" testUser1 = "user1"
testUser2 = "user2" testUser2 = "user2"
testSourceURI1 = "attachment://test1.mp3" testSourceURI1 = "upload://test1.mp3"
testSourceURI2 = "attachment://test2.ogg" testSourceURI2 = "upload://test2.ogg"
testFileArtist1 = "solo artist" testFileArtist1 = "solo artist"
testFileArtist2 = "band of 2" testFileArtist2 = "band of 2"
testFileAlbum1 = "first album" testFileAlbum1 = "first album"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment