File tree Expand file tree Collapse file tree 3 files changed +18
-8
lines changed Expand file tree Collapse file tree 3 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ import { collectMetadataAsync } from './metadata';
35
35
import { printDeprecationWarnings } from './utils/printBuildInfo' ;
36
36
import {
37
37
LocalFile ,
38
+ assertProjectTarballSizeDoesNotExceedLimit ,
38
39
makeProjectMetadataFileAsync ,
39
40
makeProjectTarballAsync ,
40
41
maybeWarnAboutProjectTarballSize ,
@@ -277,10 +278,7 @@ async function uploadProjectAsync<TPlatform extends Platform>(
277
278
const projectTarball = await makeProjectTarballAsync ( ctx . vcsClient ) ;
278
279
279
280
maybeWarnAboutProjectTarballSize ( projectTarball . size ) ;
280
-
281
- if ( projectTarball . size > 2 * 1024 * 1024 * 1024 ) {
282
- throw new Error ( 'Project archive is too big. Maximum allowed size is 2GB.' ) ;
283
- }
281
+ assertProjectTarballSizeDoesNotExceedLimit ( projectTarball . size ) ;
284
282
285
283
projectTarballPath = projectTarball . path ;
286
284
const [ bucketKey , { metadataLocation } ] = await Promise . all ( [
Original file line number Diff line number Diff line change @@ -183,6 +183,20 @@ export function maybeWarnAboutProjectTarballSize(size: number): void {
183
183
) ;
184
184
}
185
185
186
+ const MAX_ALLOWED_PROJECT_TARBALL_SIZE =
187
+ 2 /* GiB */ * 1024 /* MiB */ * 1024 /* KiB */ * 1024 ; /* B */
188
+ export function assertProjectTarballSizeDoesNotExceedLimit ( size : number ) : void {
189
+ if ( size <= MAX_ALLOWED_PROJECT_TARBALL_SIZE ) {
190
+ return ;
191
+ }
192
+
193
+ throw new Error (
194
+ `Project archive is too big. Maximum allowed size is ${ formatBytes (
195
+ MAX_ALLOWED_PROJECT_TARBALL_SIZE
196
+ ) } .`
197
+ ) ;
198
+ }
199
+
186
200
enum ShouldCommitChanges {
187
201
Yes ,
188
202
ShowDiffFirst ,
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import chalk from 'chalk';
2
2
import fs from 'node:fs' ;
3
3
4
4
import {
5
+ assertProjectTarballSizeDoesNotExceedLimit ,
5
6
makeProjectTarballAsync ,
6
7
maybeWarnAboutProjectTarballSize ,
7
8
} from '../build/utils/repository' ;
@@ -40,10 +41,7 @@ export async function uploadAccountScopedProjectSourceAsync({
40
41
projectTarballPath = projectTarball . path ;
41
42
42
43
maybeWarnAboutProjectTarballSize ( projectTarball . size ) ;
43
-
44
- if ( projectTarball . size > 2 * 1024 * 1024 * 1024 ) {
45
- throw new Error ( 'Project archive is too big. Maximum allowed size is 2GB.' ) ;
46
- }
44
+ assertProjectTarballSizeDoesNotExceedLimit ( projectTarball . size ) ;
47
45
48
46
const projectArchiveBucketKey = await uploadAccountScopedFileAtPathToGCSAsync ( graphqlClient , {
49
47
accountId,
You can’t perform that action at this time.
0 commit comments