Merge branch 'master' of github.com:tus/tusd into v2

This commit is contained in:
Marius 2021-10-19 17:30:55 +02:00
commit bc51cb05c0
6 changed files with 30 additions and 9 deletions

View File

@ -59,3 +59,18 @@ jobs:
run: | run: |
docker build -t tusproject/tusd:$GITHUB_SHA . docker build -t tusproject/tusd:$GITHUB_SHA .
docker push tusproject/tusd:$GITHUB_SHA docker push tusproject/tusd:$GITHUB_SHA
- name: Tag docker image with release tag
if: startsWith(github.ref, 'refs/tags/')
run: |
# Extract tag name: https://stackoverflow.com/a/58178121
TAG_NAME="${GITHUB_REF#refs/*/}"
docker tag tusproject/tusd:$GITHUB_SHA tusproject/tusd:$TAG_NAME
docker push tusproject/tusd:$TAG_NAME
# Create latest tag if we have no pre-release
if [[ $TAG_NAME =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]];
then
docker tag tusproject/tusd:$GITHUB_SHA tusproject/tusd:latest
docker push tusproject/tusd:latest
fi
shell: bash

View File

@ -82,7 +82,7 @@ func ParseFlags() {
flag.BoolVar(&Flags.S3DisableSSL, "s3-disable-ssl", false, "Disable SSL and only use HTTP for communication with S3 (experimental and may be removed in the future)") flag.BoolVar(&Flags.S3DisableSSL, "s3-disable-ssl", false, "Disable SSL and only use HTTP for communication with S3 (experimental and may be removed in the future)")
flag.IntVar(&Flags.S3ConcurrentPartUploads, "s3-concurrent-part-uploads", 10, "Number of concurrent part uploads to S3 (experimental and may be removed in the future)") flag.IntVar(&Flags.S3ConcurrentPartUploads, "s3-concurrent-part-uploads", 10, "Number of concurrent part uploads to S3 (experimental and may be removed in the future)")
flag.StringVar(&Flags.GCSBucket, "gcs-bucket", "", "Use Google Cloud Storage with this bucket as storage backend (requires the GCS_SERVICE_ACCOUNT_FILE environment variable to be set)") flag.StringVar(&Flags.GCSBucket, "gcs-bucket", "", "Use Google Cloud Storage with this bucket as storage backend (requires the GCS_SERVICE_ACCOUNT_FILE environment variable to be set)")
flag.StringVar(&Flags.GCSObjectPrefix, "gcs-object-prefix", "", "Prefix for GCS object names (can't contain underscore character)") flag.StringVar(&Flags.GCSObjectPrefix, "gcs-object-prefix", "", "Prefix for GCS object names")
flag.StringVar(&Flags.AzStorage, "azure-storage", "", "Use Azure BlockBlob Storage with this container name as a storage backend (requires the AZURE_ACCOUNT_NAME and AZURE_ACCOUNT_KEY environment variable to be set)") flag.StringVar(&Flags.AzStorage, "azure-storage", "", "Use Azure BlockBlob Storage with this container name as a storage backend (requires the AZURE_ACCOUNT_NAME and AZURE_ACCOUNT_KEY environment variable to be set)")
flag.StringVar(&Flags.AzContainerAccessType, "azure-container-access-type", "", "Access type when creating a new container if it does not exist (possible values: blob, container, '')") flag.StringVar(&Flags.AzContainerAccessType, "azure-container-access-type", "", "Access type when creating a new container if it does not exist (possible values: blob, container, '')")
flag.StringVar(&Flags.AzBlobAccessTier, "azure-blob-access-tier", "", "Blob access tier when uploading new files (possible values: archive, cool, hot, '')") flag.StringVar(&Flags.AzBlobAccessTier, "azure-blob-access-tier", "", "Blob access tier when uploading new files (possible values: archive, cool, hot, '')")

View File

@ -351,7 +351,11 @@ loop:
if strings.HasSuffix(objAttrs.Name, "info") { if strings.HasSuffix(objAttrs.Name, "info") {
continue continue
} }
split := strings.Split(objAttrs.Name, "_")
fileNameParts := strings.Split(objAttrs.Name, "/")
fileName := fileNameParts[len(fileNameParts)-1]
split := strings.Split(fileName, "_")
// If the object name does not split on "_", we have a composed object. // If the object name does not split on "_", we have a composed object.
// If the object name splits on "_" in to four pieces we // If the object name splits on "_" in to four pieces we

View File

@ -447,7 +447,7 @@ func TestFilterObject(t *testing.T) {
defer gock.Off() defer gock.Off()
resp := googleBucketResponse{[]googleObjectResponse{ resp := googleBucketResponse{[]googleObjectResponse{
googleObjectResponse{Name: "test-prefix_1"}, googleObjectResponse{Name: "test_directory/test-prefix_1"},
}} }}
gock.New("https://www.googleapis.com"). gock.New("https://www.googleapis.com").

View File

@ -50,6 +50,7 @@ func TestHead(t *testing.T) {
ResHeader: map[string]string{ ResHeader: map[string]string{
"Upload-Offset": "11", "Upload-Offset": "11",
"Upload-Length": "44", "Upload-Length": "44",
"Content-Length": "44",
"Cache-Control": "no-store", "Cache-Control": "no-store",
}, },
}).Run(handler, t) }).Run(handler, t)

View File

@ -260,9 +260,9 @@ func (handler *UnroutedHandler) Middleware(h http.Handler) http.Handler {
} }
// Test if the version sent by the client is supported // Test if the version sent by the client is supported
// GET methods are not checked since a browser may visit this URL and does // GET and HEAD methods are not checked since a browser may visit this URL and does
// not include this header. This request is not part of the specification. // not include this header. GET requests are not part of the specification.
if r.Method != "GET" && r.Header.Get("Tus-Resumable") != "1.0.0" { if r.Method != "GET" && r.Method != "HEAD" && r.Header.Get("Tus-Resumable") != "1.0.0" {
handler.sendError(w, r, ErrUnsupportedVersion) handler.sendError(w, r, ErrUnsupportedVersion)
return return
} }
@ -472,6 +472,7 @@ func (handler *UnroutedHandler) HeadFile(w http.ResponseWriter, r *http.Request)
w.Header().Set("Upload-Defer-Length", UploadLengthDeferred) w.Header().Set("Upload-Defer-Length", UploadLengthDeferred)
} else { } else {
w.Header().Set("Upload-Length", strconv.FormatInt(info.Size, 10)) w.Header().Set("Upload-Length", strconv.FormatInt(info.Size, 10))
w.Header().Set("Content-Length", strconv.FormatInt(info.Size, 10))
} }
w.Header().Set("Cache-Control", "no-store") w.Header().Set("Cache-Control", "no-store")