Skip to content

Commit 3fa975f

Browse files
committed
feat(resolveConfig): stabilize "RESUME_DOWNLOAD" option
Though default it to "false"
1 parent 753dceb commit 3fa975f

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

docs/api/config-options.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,13 @@ Default: `3`
281281

282282
Set this to control how many times the downloader will attempt to recover from transient errors (like network issues) before failing.
283283

284-
### EXP_RESUME_DOWNLOAD
284+
### RESUME_DOWNLOAD
285285

286-
| Environment Variable | PackageJson |
287-
| :---------------------------: | :-----------------: |
288-
| `MONGOMS_EXP_RESUME_DOWNLOAD` | `expResumeDownload` |
286+
| Environment Variable | PackageJson |
287+
| :-----------------------: | :-----------------: |
288+
| `MONGOMS_RESUME_DOWNLOAD` | `expResumeDownload` |
289289

290-
Option `EXP_RESUME_DOWNLOAD` is used to enable / disable resuming a download of a binary instead of starting over on retries or interruptions.
291-
292-
This is a experimental option, it maybe removed, renamed or have changed behavior in the future and any version.
290+
Option `RESUME_DOWNLOAD` is used to enable / disable resuming a download of a binary instead of starting over on retries or interruptions.
293291

294292
Default: `false`
295293

packages/mongodb-memory-server-core/src/util/MongoBinaryDownload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ export class MongoBinaryDownload {
478478
/** Offset to resume from; for now a non-0 value indicates to use file "append" mode */
479479
let offset = 0;
480480

481-
if (envToBool(resolveConfig(ResolveConfigVariables.EXP_RESUME_DOWNLOAD))) {
481+
if (envToBool(resolveConfig(ResolveConfigVariables.RESUME_DOWNLOAD))) {
482482
const stat = await statPath(tempDownloadLocation);
483483

484484
if (stat && stat.size != 0) {

packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownload.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ describe('MongoBinaryDownload', () => {
432432
let key: string;
433433
let cert: string;
434434

435-
let exp_resume_before: any;
435+
let resume_before: any;
436436

437437
const totalBytes = 1024 * 10;
438438

@@ -443,13 +443,13 @@ describe('MongoBinaryDownload', () => {
443443
key = await fspromises.readFile(path.resolve(certPath, './private-key.key'), 'utf-8');
444444
cert = await fspromises.readFile(path.resolve(certPath, './certificate.crt'), 'utf-8');
445445

446-
exp_resume_before = process.env[envName(ResolveConfigVariables.EXP_RESUME_DOWNLOAD)];
446+
resume_before = process.env[envName(ResolveConfigVariables.RESUME_DOWNLOAD)];
447447
});
448448

449449
beforeEach(async () => {
450450
tmpdir = await utils.createTmpDir('mongo-mem-test-download-');
451451

452-
delete process.env[envName(ResolveConfigVariables.EXP_RESUME_DOWNLOAD)];
452+
delete process.env[envName(ResolveConfigVariables.RESUME_DOWNLOAD)];
453453
});
454454
afterEach(async () => {
455455
await utils.removeDir(tmpdir);
@@ -462,7 +462,7 @@ describe('MongoBinaryDownload', () => {
462462
});
463463

464464
afterAll(() => {
465-
process.env[envName(ResolveConfigVariables.EXP_RESUME_DOWNLOAD)] = exp_resume_before;
465+
process.env[envName(ResolveConfigVariables.RESUME_DOWNLOAD)] = resume_before;
466466
});
467467

468468
function createTestServer(
@@ -607,7 +607,7 @@ describe('MongoBinaryDownload', () => {
607607
});
608608

609609
it('should download interrupt and resume', async () => {
610-
process.env[envName(ResolveConfigVariables.EXP_RESUME_DOWNLOAD)] = 'true';
610+
process.env[envName(ResolveConfigVariables.RESUME_DOWNLOAD)] = 'true';
611611

612612
jest.spyOn(console, 'log').mockImplementation(() => void 0);
613613
createTestServer(totalBytes / 2);

packages/mongodb-memory-server-core/src/util/resolveConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export enum ResolveConfigVariables {
3535
MAX_REDIRECTS = 'MAX_REDIRECTS',
3636
MAX_RETRIES = 'MAX_RETRIES', // Added for download retry configuration
3737
DISTRO = 'DISTRO',
38-
EXP_RESUME_DOWNLOAD = 'EXP_RESUME_DOWNLOAD',
38+
RESUME_DOWNLOAD = 'EXP_RESUME_DOWNLOAD',
3939
}
4040

4141
/** The Prefix for Environmental values */
@@ -54,6 +54,7 @@ export const defaultValues = new Map<ResolveConfigVariables, string>([
5454
[ResolveConfigVariables.MD5_CHECK, 'true'],
5555
[ResolveConfigVariables.MAX_REDIRECTS, '2'],
5656
[ResolveConfigVariables.MAX_RETRIES, '3'], // Default maxRetries for downloads
57+
[ResolveConfigVariables.RESUME_DOWNLOAD, 'false'],
5758
]);
5859

5960
/** Interface for storing information about the found package.json from `findPackageJson` */

0 commit comments

Comments
 (0)