mirror of
https://github.com/whyour/qinglong.git
synced 2025-11-09 16:16:07 +08:00
Merge df7f13c6bf into 73f8f3c5fa
This commit is contained in:
commit
9d61530da4
|
|
@ -26,13 +26,13 @@ export default class SshKeyService {
|
||||||
if (_exist) {
|
if (_exist) {
|
||||||
config = await fs.readFile(this.sshConfigFilePath, { encoding: 'utf-8' });
|
config = await fs.readFile(this.sshConfigFilePath, { encoding: 'utf-8' });
|
||||||
} else {
|
} else {
|
||||||
await writeFileWithLock(this.sshConfigFilePath, '', { mode: '600' });
|
await writeFileWithLock(this.sshConfigFilePath, '', { mode: 0o600 });
|
||||||
}
|
}
|
||||||
if (!config.includes(this.sshConfigHeader)) {
|
if (!config.includes(this.sshConfigHeader)) {
|
||||||
await writeFileWithLock(
|
await writeFileWithLock(
|
||||||
this.sshConfigFilePath,
|
this.sshConfigFilePath,
|
||||||
`${this.sshConfigHeader}\n\n${config}`,
|
`${this.sshConfigHeader}\n\n${config}`,
|
||||||
{ mode: '600' },
|
{ mode: 0o600 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +46,7 @@ export default class SshKeyService {
|
||||||
path.join(this.sshPath, alias),
|
path.join(this.sshPath, alias),
|
||||||
`${key}${os.EOL}`,
|
`${key}${os.EOL}`,
|
||||||
{
|
{
|
||||||
mode: '400',
|
mode: 0o400,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -83,7 +83,7 @@ export default class SshKeyService {
|
||||||
config,
|
config,
|
||||||
{
|
{
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
mode: '600',
|
mode: 0o600,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,13 @@ export async function writeFileWithLock(
|
||||||
if (typeof options === 'string') {
|
if (typeof options === 'string') {
|
||||||
options = { encoding: options };
|
options = { encoding: options };
|
||||||
}
|
}
|
||||||
|
let isNewFile = false;
|
||||||
if (!(await fileExist(filePath))) {
|
if (!(await fileExist(filePath))) {
|
||||||
const fileHandle = await open(filePath, 'w');
|
// Create the file with the specified mode if provided, otherwise use default
|
||||||
fileHandle.close();
|
const fileMode = options?.mode || 0o666;
|
||||||
|
const fileHandle = await open(filePath, 'w', fileMode);
|
||||||
|
await fileHandle.close();
|
||||||
|
isNewFile = true;
|
||||||
}
|
}
|
||||||
const lockfilePath = getUniqueLockPath(filePath);
|
const lockfilePath = getUniqueLockPath(filePath);
|
||||||
|
|
||||||
|
|
@ -35,7 +39,8 @@ export async function writeFileWithLock(
|
||||||
lockfilePath,
|
lockfilePath,
|
||||||
});
|
});
|
||||||
await writeFile(filePath, content, { encoding: 'utf8', ...options });
|
await writeFile(filePath, content, { encoding: 'utf8', ...options });
|
||||||
if (options?.mode) {
|
// Only chmod if the file already existed (not just created with the correct mode)
|
||||||
|
if (!isNewFile && options?.mode) {
|
||||||
await chmod(filePath, options.mode);
|
await chmod(filePath, options.mode);
|
||||||
}
|
}
|
||||||
await release();
|
await release();
|
||||||
|
|
|
||||||
22508
pnpm-lock.yaml
22508
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user