@@ -33,24 +33,73 @@ export class MongoBinaryDownload {
3333 dlProgress : MongoBinaryDownloadProgress ;
3434 _downloadingUrl ?: string ;
3535
36- checkMD5 : boolean ;
37- downloadDir : string ;
38- arch : string ;
39- version : string ;
40- platform : string ;
41-
42- constructor ( { platform, arch, downloadDir, version, checkMD5 } : MongoBinaryOpts ) {
43- this . platform = platform ?? os . platform ( ) ;
44- this . arch = arch ?? os . arch ( ) ;
45- version = version ?? resolveConfig ( ResolveConfigVariables . VERSION ) ;
36+ /**These options are kind of raw, they are not run through DryMongoBinary.generateOptions */
37+ binaryOpts : Required < MongoBinaryOpts > ;
38+
39+ // TODO: for an major version, remove the compat get/set
40+ // the following get/set are to not break existing stuff
41+
42+ get checkMD5 ( ) : boolean {
43+ return this . binaryOpts . checkMD5 ;
44+ }
45+
46+ set checkMD5 ( val : boolean ) {
47+ this . binaryOpts . checkMD5 = val ;
48+ }
49+
50+ get downloadDir ( ) : string {
51+ return this . binaryOpts . downloadDir ;
52+ }
53+
54+ set downloadDir ( val : string ) {
55+ this . binaryOpts . downloadDir = val ;
56+ }
57+
58+ get arch ( ) : string {
59+ return this . binaryOpts . arch ;
60+ }
61+
62+ set arch ( val : string ) {
63+ this . binaryOpts . arch = val ;
64+ }
65+
66+ get version ( ) : string {
67+ return this . binaryOpts . version ;
68+ }
69+
70+ set version ( val : string ) {
71+ this . binaryOpts . version = val ;
72+ }
73+
74+ get platform ( ) : string {
75+ return this . binaryOpts . platform ;
76+ }
77+
78+ set platform ( val : string ) {
79+ this . binaryOpts . platform = val ;
80+ }
81+
82+ // end get/set backwards compat section
83+
84+ constructor ( opts : MongoBinaryOpts ) {
85+ assertion ( typeof opts . downloadDir === 'string' , new Error ( 'An DownloadDir must be specified!' ) ) ;
86+ const version = opts . version ?? resolveConfig ( ResolveConfigVariables . VERSION ) ;
4687 assertion (
4788 typeof version === 'string' ,
4889 new Error ( 'An MongoDB Binary version must be specified!' )
4990 ) ;
50- assertion ( typeof downloadDir === 'string' , new Error ( 'An DownloadDir must be specified!' ) ) ;
51- this . version = version ;
52- this . downloadDir = downloadDir ;
53- this . checkMD5 = checkMD5 ?? envToBool ( resolveConfig ( ResolveConfigVariables . MD5_CHECK ) ) ;
91+
92+ // DryMongoBinary.generateOptions cannot be used here, because its async
93+ this . binaryOpts = {
94+ platform : opts . platform ?? os . platform ( ) ,
95+ arch : opts . arch ?? os . arch ( ) ,
96+ version : version ,
97+ downloadDir : opts . downloadDir ,
98+ checkMD5 : opts . checkMD5 ?? envToBool ( resolveConfig ( ResolveConfigVariables . MD5_CHECK ) ) ,
99+ systemBinary : opts . systemBinary ?? '' ,
100+ os : opts . os ?? { os : 'unknown' } ,
101+ } ;
102+
54103 this . dlProgress = {
55104 current : 0 ,
56105 length : 0 ,
@@ -64,11 +113,7 @@ export class MongoBinaryDownload {
64113 * @return Absoulte Path with FileName
65114 */
66115 protected async getPath ( ) : Promise < string > {
67- const opts = await DryMongoBinary . generateOptions ( {
68- version : this . version ,
69- arch : this . arch ,
70- downloadDir : this . downloadDir ,
71- } ) ;
116+ const opts = await DryMongoBinary . generateOptions ( this . binaryOpts ) ;
72117
73118 return DryMongoBinary . combineBinaryName ( this . downloadDir , DryMongoBinary . getBinaryName ( opts ) ) ;
74119 }
@@ -104,11 +149,7 @@ export class MongoBinaryDownload {
104149 */
105150 async startDownload ( ) : Promise < string > {
106151 log ( 'startDownload' ) ;
107- const mbdUrl = new MongoBinaryDownloadUrl ( {
108- platform : this . platform ,
109- arch : this . arch ,
110- version : this . version ,
111- } ) ;
152+ const mbdUrl = new MongoBinaryDownloadUrl ( this . binaryOpts ) ;
112153
113154 await mkdirp ( this . downloadDir ) ;
114155
0 commit comments