From 765787d424d8fff37dc843ed2fedc12bce419c51 Mon Sep 17 00:00:00 2001 From: Christian Pointner <equinox@helsinki.at> Date: Sun, 9 Sep 2018 19:30:06 +0200 Subject: [PATCH] rename attachment to upload --- importer/importer.go | 2 +- importer/job.go | 6 +++--- importer/job_source.go | 16 ++++++++-------- importer/types.go | 4 ++-- store/store_test.go | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/importer/importer.go b/importer/importer.go index ad2c970..7e17a1e 100644 --- a/importer/importer.go +++ b/importer/importer.go @@ -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) { // TODO: update this list once we implemented other sources switch src.Scheme { - case SourceSchemeAttachment: + case SourceSchemeUpload: case SourceSchemeFake: default: return nil, ErrSourceNotSupported diff --git a/importer/job.go b/importer/job.go index c579540..9bd3c0c 100644 --- a/importer/job.go +++ b/importer/job.go @@ -159,14 +159,14 @@ func (job *Job) AttachSource(length uint64, r io.Reader) (<-chan *JobSourceResul return nil, ErrImportNotRunning } - // only allow to attach external sources if the job's source was in fact an attachment URL - if job.Source.Scheme != SourceSchemeAttachment { + // only allow to attach external sources if the job's source was in fact an upload URL + if job.Source.Scheme != SourceSchemeUpload { return nil, ErrSourceAlreadyAttached } if ok := atomic.CompareAndSwapUint32(&job.sourceSet, 0, 1); !ok { return nil, ErrSourceAlreadyAttached } - src := newJobSourceAttachment(length, r) + src := newJobSourceUpload(length, r) job.source = src close(job.subC.sourceAttached) return src.done, nil diff --git a/importer/job_source.go b/importer/job_source.go index 48e39f3..5b1d4b4 100644 --- a/importer/job_source.go +++ b/importer/job_source.go @@ -31,7 +31,7 @@ import ( ) 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 // is to wait for it to happen select { @@ -85,29 +85,29 @@ func (src *JobSourceFake) Done(result *JobSourceResult) { return } -//******* Attachment +//******* Upload -type JobSourceAttachment struct { +type JobSourceUpload struct { len uint64 r io.Reader done chan *JobSourceResult } -func newJobSourceAttachment(len uint64, r io.Reader) *JobSourceAttachment { - src := &JobSourceAttachment{len: len, r: r} +func newJobSourceUpload(len uint64, r io.Reader) *JobSourceUpload { + src := &JobSourceUpload{len: len, r: r} src.done = make(chan *JobSourceResult, 1) return src } -func (src *JobSourceAttachment) Len() uint64 { +func (src *JobSourceUpload) Len() uint64 { 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) } -func (src *JobSourceAttachment) Done(result *JobSourceResult) { +func (src *JobSourceUpload) Done(result *JobSourceResult) { if result == nil { close(src.done) return diff --git a/importer/types.go b/importer/types.go index c5d1082..acd4e30 100644 --- a/importer/types.go +++ b/importer/types.go @@ -38,8 +38,8 @@ import ( const ( DefaultBacklog = 100 - SourceSchemeAttachment = "attachment" - SourceSchemeFake = "fake" + SourceSchemeUpload = "upload" + SourceSchemeFake = "fake" ) //******* Errors diff --git a/store/store_test.go b/store/store_test.go index c4e0d16..8a0a89b 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -46,8 +46,8 @@ var ( testGroup2 = "test2" testUser1 = "user1" testUser2 = "user2" - testSourceURI1 = "attachment://test1.mp3" - testSourceURI2 = "attachment://test2.ogg" + testSourceURI1 = "upload://test1.mp3" + testSourceURI2 = "upload://test2.ogg" testFileArtist1 = "solo artist" testFileArtist2 = "band of 2" testFileAlbum1 = "first album" -- GitLab