File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,21 +5,18 @@ import { devBranchPathSegment } from "../utilities/devBranch.js";
55import { logger } from "../utilities/logger.js" ;
66import { mkdir , writeFile } from "node:fs/promises" ;
77import { existsSync , unlinkSync } from "node:fs" ;
8- import { createHash } from "node:crypto" ;
98import { onExit } from "signal-exit" ;
109
1110const LOCK_FILE_NAME = "dev.lock" ;
1211
1312/**
1413 * Builds the lock file name for a given branch. The default branch keeps the
1514 * original `dev.lock` name (backwards compatible).
16- * Throws in a SHA1 of the non-sanitized filename to prevent collision
1715 */
1816function lockFileName ( branch ?: string ) {
1917 const safeBranch = devBranchPathSegment ( branch ) ;
20- if ( ! safeBranch || ! branch ) return LOCK_FILE_NAME ;
21- const branchHash = createHash ( "sha1" ) . update ( branch ) . digest ( "hex" ) . slice ( 0 , 8 ) ;
22- return `dev.${ safeBranch } .${ branchHash } .lock` ;
18+ if ( ! safeBranch ) return LOCK_FILE_NAME ;
19+ return `dev.${ safeBranch } .lock` ;
2320}
2421
2522export async function createLockFile ( cwd : string , branch ?: string ) {
Original file line number Diff line number Diff line change 1+ import { createHash } from "node:crypto" ;
12import { isDefaultDevBranch } from "@trigger.dev/core/v3/utils/gitBranch" ;
23
34/**
@@ -15,5 +16,7 @@ export function devBranchPathSegment(branch?: string): string | undefined {
1516 }
1617
1718 // Branch names can contain filesystem-unsafe characters (e.g. "/"), so sanitize.
18- return branch . replace ( / [ ^ a - z A - Z 0 - 9 - _ ] / g, "-" ) ;
19+ const sanitized = branch . replace ( / [ ^ a - z A - Z 0 - 9 - _ ] / g, "-" ) ;
20+ const branchHash = createHash ( "sha1" ) . update ( branch ) . digest ( "hex" ) . slice ( 0 , 8 ) ;
21+ return `${ sanitized } -${ branchHash } ` ;
1922}
You can’t perform that action at this time.
0 commit comments