@@ -10,11 +10,14 @@ import (
10
10
"os/exec"
11
11
"path"
12
12
"path/filepath"
13
+ "strings"
13
14
15
+ "github.com/andybalholm/brotli"
14
16
"github.com/docker/docker/api/types/container"
15
17
"github.com/docker/docker/api/types/network"
16
18
"github.com/go-errors/errors"
17
19
"github.com/spf13/afero"
20
+ "github.com/spf13/viper"
18
21
"github.com/supabase/cli/internal/utils"
19
22
"github.com/supabase/cli/internal/utils/flags"
20
23
"github.com/supabase/cli/pkg/api"
@@ -121,11 +124,13 @@ func Run(ctx context.Context, slug string, projectRef string, useLegacyBundle bo
121
124
if err != nil {
122
125
return err
123
126
}
124
- defer func () {
125
- if err := fsys .Remove (eszipPath ); err != nil {
126
- fmt .Fprintln (os .Stderr , err )
127
- }
128
- }()
127
+ if ! viper .GetBool ("DEBUG" ) {
128
+ defer func () {
129
+ if err := fsys .Remove (eszipPath ); err != nil {
130
+ fmt .Fprintln (os .Stderr , err )
131
+ }
132
+ }()
133
+ }
129
134
// Extract eszip to functions directory
130
135
err = extractOne (ctx , slug , eszipPath )
131
136
if err != nil {
@@ -148,12 +153,16 @@ func downloadOne(ctx context.Context, slug, projectRef string, fsys afero.Fs) (s
148
153
}
149
154
return "" , errors .Errorf ("Error status %d: %s" , resp .StatusCode , string (body ))
150
155
}
156
+ r := io .Reader (resp .Body )
157
+ if strings .EqualFold (resp .Header .Get ("Content-Encoding" ), "br" ) {
158
+ r = brotli .NewReader (resp .Body )
159
+ }
151
160
// Create temp file to store downloaded eszip
152
161
eszipPath := filepath .Join (utils .TempDir , fmt .Sprintf ("output_%s.eszip" , slug ))
153
162
if err := utils .MkdirIfNotExistFS (fsys , utils .TempDir ); err != nil {
154
163
return "" , err
155
164
}
156
- if err := afero .WriteReader (fsys , eszipPath , resp . Body ); err != nil {
165
+ if err := afero .WriteReader (fsys , eszipPath , r ); err != nil {
157
166
return "" , errors .Errorf ("failed to download file: %w" , err )
158
167
}
159
168
return eszipPath , nil
0 commit comments