uppercase ID and URL to match golint

This commit is contained in:
Acconut 2015-03-23 17:58:13 +01:00
parent 39f919c8aa
commit c49f7bbf91
3 changed files with 11 additions and 11 deletions

View File

@ -7,7 +7,7 @@ import (
type MetaData map[string]string type MetaData map[string]string
type FileInfo struct { type FileInfo struct {
Id string ID string
// Total file size in bytes specified in the NewUpload call // Total file size in bytes specified in the NewUpload call
Size int64 Size int64
// Offset in bytes (zero-based) // Offset in bytes (zero-based)

View File

@ -28,7 +28,7 @@ type FileStore struct {
func (store FileStore) NewUpload(info tusd.FileInfo) (id string, err error) { func (store FileStore) NewUpload(info tusd.FileInfo) (id string, err error) {
id = uid.Uid() id = uid.Uid()
info.Id = id info.ID = id
// Create .bin file with no content // Create .bin file with no content
file, err := os.OpenFile(store.binPath(id), os.O_CREATE|os.O_WRONLY, defaultFilePerm) file, err := os.OpenFile(store.binPath(id), os.O_CREATE|os.O_WRONLY, defaultFilePerm)

View File

@ -17,7 +17,7 @@ import (
var logger = log.New(os.Stdout, "[tusd] ", 0) var logger = log.New(os.Stdout, "[tusd] ", 0)
var reExtractFileId = regexp.MustCompile(`([^/]+)\/?$`) var reExtractFileID = regexp.MustCompile(`([^/]+)\/?$`)
var ( var (
ErrUnsupportedVersion = errors.New("unsupported version") ErrUnsupportedVersion = errors.New("unsupported version")
@ -80,7 +80,7 @@ func NewHandler(config Config) (*Handler, error) {
return nil, err return nil, err
} }
// Ensure base path ends with slash to remove logic from absFileUrl // Ensure base path ends with slash to remove logic from absFileURL
if base != "" && string(base[len(base)-1]) != "/" { if base != "" && string(base[len(base)-1]) != "/" {
base += "/" base += "/"
} }
@ -218,7 +218,7 @@ func (handler *Handler) postFile(w http.ResponseWriter, r *http.Request) {
} }
} }
url := handler.absFileUrl(r, id) url := handler.absFileURL(r, id)
w.Header().Set("Location", url) w.Header().Set("Location", url)
w.WriteHeader(http.StatusCreated) w.WriteHeader(http.StatusCreated)
} }
@ -239,8 +239,8 @@ func (handler *Handler) headFile(w http.ResponseWriter, r *http.Request) {
if info.IsFinal { if info.IsFinal {
v := "final;" v := "final;"
for _, uploadId := range info.PartialUploads { for _, uploadID := range info.PartialUploads {
v += " " + handler.absFileUrl(r, uploadId) v += " " + handler.absFileURL(r, uploadID)
} }
w.Header().Set("Concat", v) w.Header().Set("Concat", v)
} }
@ -411,7 +411,7 @@ func (handler *Handler) sendError(w http.ResponseWriter, err error) {
// Make an absolute URLs to the given upload id. If the base path is absolute // Make an absolute URLs to the given upload id. If the base path is absolute
// it will be prepended else the host and protocol from the request is used. // it will be prepended else the host and protocol from the request is used.
func (handler *Handler) absFileUrl(r *http.Request, id string) string { func (handler *Handler) absFileURL(r *http.Request, id string) string {
if handler.isBasePathAbs { if handler.isBasePathAbs {
return handler.basePath + id return handler.basePath + id
} }
@ -453,8 +453,8 @@ func (handler *Handler) sizeOfUploads(ids []string) (size int64, err error) {
func (handler *Handler) fillFinalUpload(id string, uploads []string) error { func (handler *Handler) fillFinalUpload(id string, uploads []string) error {
readers := make([]io.Reader, len(uploads)) readers := make([]io.Reader, len(uploads))
for index, uploadId := range uploads { for index, uploadID := range uploads {
reader, err := handler.dataStore.GetReader(uploadId) reader, err := handler.dataStore.GetReader(uploadID)
if err != nil { if err != nil {
return err return err
} }
@ -537,7 +537,7 @@ func parseConcat(header string) (isPartial bool, isFinal bool, partialUploads []
} }
// Extract ids out of URL // Extract ids out of URL
result := reExtractFileId.FindStringSubmatch(value) result := reExtractFileID.FindStringSubmatch(value)
if len(result) != 2 { if len(result) != 2 {
err = ErrInvalidConcat err = ErrInvalidConcat
return return