Skip to content

Commit

Permalink
fix: cross-device link error on release upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoffroy Empain committed Mar 19, 2021
1 parent 833b62f commit 7c261f1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/entities/sites/handlers/releases/upload-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { configureSiteInCaddy } from '../../../../caddy/configuration';
import { Logger } from '../../../../commons/logger/logger';
import { slugify } from '../../../../utils/slugify';
import { parseConfig } from '../../yaml-config/parse-config';
import { env } from '../../../../env/env';
import path from 'path';

async function findOrCreateBranch(site: Site, branchName: string): Promise<Branch> {
let branch: Branch = site.branches.find(c => c.name === branchName);
Expand Down Expand Up @@ -76,14 +78,20 @@ async function setBranchRelease(site: Site, branch: Branch, release: Release): P

const logger = new Logger('meli.api:uploadRelease');

async function getExtractPath(): Promise<string> {
const tmpSiteDir = path.join(env.MELI_SITES_DIR, 'tmp');
await promises.mkdir(tmpSiteDir, { recursive: true });
return path.join(tmpSiteDir, uuid());
}

async function handler(req: Request, res: Response): Promise<void> {
const { file } = req;
const { siteId } = req.params;
const branchNames: string[] = req.body.branches;

logger.debug('file uploaded at', file.path);

const extractPath = await promises.mkdtemp('release');
const extractPath = await getExtractPath();

await extractReleaseFiles(file, extractPath);

Expand Down

0 comments on commit 7c261f1

Please sign in to comment.