@@ -11,7 +11,6 @@ import (
1111 "log"
1212 "net/http"
1313 "os"
14- "path/filepath"
1514 "strconv"
1615 "time"
1716
3433 R2_KEY_SECRET = os .Getenv ("R2_KEY_SECRET" )
3534 R2_ENDPOINT = os .Getenv ("R2_ENDPOINT" )
3635
37- // In an attempt to spread the load across multiple gcp functions, we split
38- // the upload per file extension (either gz, br or woff2). There should
39- // be 50/50 for gz and br. Unknown for woff2.
40- // Example: FILE_EXTENSION=gz
41- FILE_EXTENSION = os .Getenv ("FILE_EXTENSION" )
42-
4336 UPLOAD_CONCURENCY = os .Getenv ("UPLOAD_CONCURENCY" )
4437)
4538
@@ -97,7 +90,6 @@ func InvokeInner(d InvokePayload, ctx context.Context) error {
9790 }
9891
9992 onFile := func (name string , r io.Reader ) error {
100- ext := filepath .Ext (name )
10193 // remove leading slash
10294 name = name [1 :]
10395 key := fmt .Sprintf ("%s/%s/%s" , pkgName , version , name )
@@ -107,19 +99,17 @@ func InvokeInner(d InvokePayload, ctx context.Context) error {
10799 return errors .Wrap (err , "could not read file" )
108100 }
109101
110- if ext == "." + FILE_EXTENSION {
111- keys = append (keys , key )
102+ keys = append (keys , key )
112103
113- meta := newMetadata (len (content ))
104+ meta := newMetadata (len (content ))
114105
115- s3Object := s3.PutObjectInput {
116- Body : bytes .NewReader (content ),
117- Bucket : bucket ,
118- Key : aws .String (key ),
119- Metadata : meta ,
120- }
121- uploadQueue <- s3Object
106+ s3Object := s3.PutObjectInput {
107+ Body : bytes .NewReader (content ),
108+ Bucket : bucket ,
109+ Key : aws .String (key ),
110+ Metadata : meta ,
122111 }
112+ uploadQueue <- s3Object
123113 return nil
124114 }
125115 if err := gcp .Inflate (bytes .NewReader (archive ), onFile ); err != nil {
@@ -136,7 +126,7 @@ func InvokeInner(d InvokePayload, ctx context.Context) error {
136126 return fmt .Errorf ("failed to parse config: %s" , err )
137127 }
138128
139- if err := audit .WroteR2 (ctx , pkgName , version , keys , FILE_EXTENSION ); err != nil {
129+ if err := audit .WroteR2 (ctx , pkgName , version , keys ); err != nil {
140130 log .Printf ("failed to audit: %s\n " , err )
141131 }
142132 if err := metrics .NewUpdatePublishedR2 (); err != nil {
0 commit comments