Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion git-ai/src/services/ConflictResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,14 @@ export class ConflictResolver {
// Atomic write: write to a temp file, fsync, then rename into place.
const tempPath = path.join(targetParent, `.tmp-${process.pid}-${randomBytes(8).toString('hex')}`);
const buffer = Buffer.from(resolvedContent, 'utf-8');
const tempHandle = await fs.open(tempPath, fs.constants.O_CREAT | fs.constants.O_EXCL | fs.constants.O_WRONLY | fs.constants.O_NOFOLLOW, 0o644);
let fileMode = 0o644;
try {
const stat = await fs.lstat(targetPath);
fileMode = stat.mode & 0o777;
} catch {
// Target does not exist; use default mode 0o644
}
const tempHandle = await fs.open(tempPath, fs.constants.O_CREAT | fs.constants.O_EXCL | fs.constants.O_WRONLY | fs.constants.O_NOFOLLOW, fileMode);
try {
await tempHandle.writeFile(buffer);
await tempHandle.sync();
Expand Down