Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[expo-cli] Fix parallel uploads #2736

Merged
merged 2 commits into from Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -18,6 +18,7 @@ jest.mock('got', () => {
},
};
});
jest.mock('temp-dir', () => '/tmp');
jest.mock('../files', () => {
const filesModule = jest.requireActual('../files');
return {
Expand All @@ -31,6 +32,7 @@ jest.mock('../files', () => {
});

beforeAll(async () => {
vol.mkdirpSync('/tmp');
vol.writeFileSync(
'/apk-archive.tar.gz',
originalFs.readFileSync(path.join(__dirname, 'fixtures/apk-archive.tar.gz'))
Expand Down
Expand Up @@ -2,10 +2,10 @@ import fs from 'fs-extra';
import { sync as globSync } from 'glob';
import got from 'got';
import Request from 'got/dist/source/core';
import os from 'os';
import { basename, extname, join } from 'path';
import stream from 'stream';
import tar from 'tar';
import temporary from 'tempy';
import { promisify } from 'util';

import { uploadAsync, UploadType } from '../../../../uploads';
Expand Down Expand Up @@ -57,7 +57,7 @@ async function downloadAppArchiveAsync(url: string): Promise<string> {
const filename = basename(url);
// Since we may need to rename the destination path,
// add everything to a folder which can be nuked to ensure we don't accidentally use an old build with the same name.
const destinationFolder = await createTemporaryDirectoryForExtractionAsync();
const destinationFolder = temporary.directory();
const destinationPath = join(destinationFolder, filename);

const downloadStream = createDownloadStream(url);
Expand All @@ -81,19 +81,6 @@ async function uploadAppArchiveAsync(path: string): Promise<string> {
);
}

async function createTemporaryDirectoryForExtractionAsync(): Promise<string> {
// Since we may need to rename the destination path,
// add everything to a folder which can be nuked to ensure we don't accidentally use an old build with the same name.
const destinationFolder = join(os.tmpdir(), 'expo-submission-service');

if (await fs.pathExists(destinationFolder)) {
await fs.remove(destinationFolder);
}
await fs.ensureDir(destinationFolder);

return destinationFolder;
}

async function decompressTarAsync(src: string, destination: string): Promise<void> {
await pipeline(fs.createReadStream(src), tar.extract({ cwd: destination }, []));
}
Expand All @@ -108,7 +95,7 @@ async function extractLocalArchiveAsync(filePath: string): Promise<string> {
const filename = basename(filePath);
// Since we may need to rename the destination path,
// add everything to a folder which can be nuked to ensure we don't accidentally use an old build with the same name.
const destinationFolder = await createTemporaryDirectoryForExtractionAsync();
const destinationFolder = temporary.directory();
const destinationPath = join(destinationFolder, filename);

// Special use-case for downloading an EAS tar.gz file and unpackaging it.
Expand Down