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 FileInfo struct {
Id string
ID string
// Total file size in bytes specified in the NewUpload call
Size int64
// 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) {
id = uid.Uid()
info.Id = id
info.ID = id
// Create .bin file with no content
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 reExtractFileId = regexp.MustCompile(`([^/]+)\/?$`)
var reExtractFileID = regexp.MustCompile(`([^/]+)\/?$`)
var (
ErrUnsupportedVersion = errors.New("unsupported version")
@ -80,7 +80,7 @@ func NewHandler(config Config) (*Handler, error) {
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]) != "/" {
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.WriteHeader(http.StatusCreated)
}
@ -239,8 +239,8 @@ func (handler *Handler) headFile(w http.ResponseWriter, r *http.Request) {
if info.IsFinal {
v := "final;"
for _, uploadId := range info.PartialUploads {
v += " " + handler.absFileUrl(r, uploadId)
for _, uploadID := range info.PartialUploads {
v += " " + handler.absFileURL(r, uploadID)
}
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
// 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 {
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 {
readers := make([]io.Reader, len(uploads))
for index, uploadId := range uploads {
reader, err := handler.dataStore.GetReader(uploadId)
for index, uploadID := range uploads {
reader, err := handler.dataStore.GetReader(uploadID)
if err != nil {
return err
}
@ -537,7 +537,7 @@ func parseConcat(header string) (isPartial bool, isFinal bool, partialUploads []
}
// Extract ids out of URL
result := reExtractFileId.FindStringSubmatch(value)
result := reExtractFileID.FindStringSubmatch(value)
if len(result) != 2 {
err = ErrInvalidConcat
return