Commit 6c208574 authored by Quentin Smith's avatar Quentin Smith

storage/app: rename upload metadata

- uploadid -> upload
- fileid -> upload-part
- uploadtime -> upload-time
- uploadfile -> upload-file

Change-Id: I3b8a989d83a620a186c986fdd98e920868e9d089
Reviewed-on: https://go-review.googlesource.com/35492Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent 0d0e3243
...@@ -24,8 +24,8 @@ func TestQuery(t *testing.T) { ...@@ -24,8 +24,8 @@ func TestQuery(t *testing.T) {
// number). So 1 record has each value of label0, 2 records // number). So 1 record has each value of label0, 2 records
// have each value of label1, 4 records have each value of // have each value of label1, 4 records have each value of
// label2, etc. This allows writing queries that match 2^n records. // label2, etc. This allows writing queries that match 2^n records.
app.uploadFiles(t, func(mpw *multipart.Writer) { status := app.uploadFiles(t, func(mpw *multipart.Writer) {
w, err := mpw.CreateFormFile("file", "1.txt") w, err := mpw.CreateFormFile("file", "path/1.txt")
if err != nil { if err != nil {
t.Errorf("CreateFormFile: %v", err) t.Errorf("CreateFormFile: %v", err)
} }
...@@ -68,6 +68,15 @@ func TestQuery(t *testing.T) { ...@@ -68,6 +68,15 @@ func TestQuery(t *testing.T) {
t.Fatalf("#%d: Next() = false, want true (Err() = %v)", i, br.Err()) t.Fatalf("#%d: Next() = false, want true (Err() = %v)", i, br.Err())
} }
r := br.Result() r := br.Result()
if r.Labels["upload"] != status.UploadID {
t.Errorf("#%d: upload = %q, want %q", r.Labels["upload"], status.UploadID)
}
if r.Labels["upload-part"] != status.FileIDs[0] {
t.Errorf("#%d: upload-part = %q, want %q", r.Labels["upload-part"], status.FileIDs[0])
}
if r.Labels["upload-file"] != "1.txt" {
t.Errorf("#%d: upload-file = %q, want %q", r.Labels["upload-file"], "1.txt")
}
if r.Labels["label0"] != fmt.Sprintf("%d", num) { if r.Labels["label0"] != fmt.Sprintf("%d", num) {
t.Errorf("#%d: label0 = %q, want %d", i, r.Labels["label0"], num) t.Errorf("#%d: label0 = %q, want %d", i, r.Labels["label0"], num)
} }
......
...@@ -119,16 +119,16 @@ func (a *App) processUpload(ctx context.Context, user string, mr *multipart.Read ...@@ -119,16 +119,16 @@ func (a *App) processUpload(ctx context.Context, user string, mr *multipart.Read
// be rejected and the Cloud Storage upload aborted. // be rejected and the Cloud Storage upload aborted.
meta := map[string]string{ meta := map[string]string{
"uploadid": upload.ID, "upload": upload.ID,
"fileid": fmt.Sprintf("%s/%d", upload.ID, i), "upload-part": fmt.Sprintf("%s/%d", upload.ID, i),
"uploadtime": uploadtime, "upload-time": uploadtime,
} }
name = p.FileName() name = p.FileName()
if slash := strings.LastIndexAny(name, `/\`); slash >= 0 { if slash := strings.LastIndexAny(name, `/\`); slash >= 0 {
name = name[slash+1:] name = name[slash+1:]
} }
if name != "" { if name != "" {
meta["uploadfile"] = name meta["upload-file"] = name
} }
if user != "" { if user != "" {
meta["by"] = user meta["by"] = user
...@@ -144,7 +144,7 @@ func (a *App) processUpload(ctx context.Context, user string, mr *multipart.Read ...@@ -144,7 +144,7 @@ func (a *App) processUpload(ctx context.Context, user string, mr *multipart.Read
return nil, err return nil, err
} }
fileids = append(fileids, meta["fileid"]) fileids = append(fileids, meta["upload-part"])
} }
if upload == nil { if upload == nil {
...@@ -165,7 +165,7 @@ func (a *App) processUpload(ctx context.Context, user string, mr *multipart.Read ...@@ -165,7 +165,7 @@ func (a *App) processUpload(ctx context.Context, user string, mr *multipart.Read
} }
func (a *App) indexFile(ctx context.Context, upload *db.Upload, p io.Reader, meta map[string]string) (err error) { func (a *App) indexFile(ctx context.Context, upload *db.Upload, p io.Reader, meta map[string]string) (err error) {
fw, err := a.FS.NewWriter(ctx, fmt.Sprintf("uploads/%s.txt", meta["fileid"]), meta) fw, err := a.FS.NewWriter(ctx, fmt.Sprintf("uploads/%s.txt", meta["upload-part"]), meta)
if err != nil { if err != nil {
return err return err
} }
......
...@@ -21,4 +21,4 @@ env_variables: ...@@ -21,4 +21,4 @@ env_variables:
CLOUDSQL_PASSWORD: "" CLOUDSQL_PASSWORD: ""
CLOUDSQL_DATABASE: "perfdata" CLOUDSQL_DATABASE: "perfdata"
GCS_BUCKET: "golang-perfdata" GCS_BUCKET: "golang-perfdata"
PERFDATA_VIEW_URL_BASE: "https://perf.golang.org/search?q=uploadid:" PERFDATA_VIEW_URL_BASE: "https://perf.golang.org/search?q=upload:"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment