Skip to content

Commit

Permalink
feat(bundles ans-104): include random component in ans-104 tmp file n…
Browse files Browse the repository at this point in the history
…ame PE-4306

Adds a random component to file name of the temp file used to pass
ANS-104 bundles from the main thread to the ANS-104 unbundling workers.
This is to prevent potential write conflicts when unbundling in
parallel.
  • Loading branch information
djwhitt committed Aug 8, 2023
1 parent 7499e9e commit e84b52c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/lib/ans-104.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ export function normalizeAns104DataItem({
filter: string;
ans104DataItem: Record<string, any>;
}): NormalizedDataItem {
// TODO stricter type checking (maybe zod)

const tags = (ans104DataItem.tags || []).map(
(tag: { name: string; value: string }) => ({
name: utf8ToB64Url(tag.name),
Expand Down Expand Up @@ -189,7 +187,7 @@ export class Ans104Parser {
const bundlePath = path.join(
process.cwd(),
'data/tmp/ans-104',
`${parentId}`,
`${parentId}-${Math.random().toString(36).substring(2, 15)}`,
);
const writeStream = fs.createWriteStream(bundlePath);
pipeline(data.stream, writeStream, (error) => {
Expand Down

0 comments on commit e84b52c

Please sign in to comment.