Skip to content

Commit

Permalink
fix: path bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mlhiter committed Nov 13, 2024
1 parent 7ae2182 commit d67b6fe
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion extensions/ide/vscode/devbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "devbox-aio",
"displayName": "Devbox",
"description": "help code for cloud devbox in sailos/sealos",
"version": "1.0.1",
"version": "1.0.3",
"keywords": [
"devbox",
"remote development",
Expand Down
12 changes: 8 additions & 4 deletions extensions/ide/vscode/devbox/src/commands/remoteConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ export class RemoteSSHConnector extends Disposable {
}

private replaceHomePathInConfig(content: string): string {
return content.replace(
/Include ~\/.ssh\/sealos\/devbox_config/g,
`Include ${os.homedir()}/.ssh/sealos/devbox_config`
)
const includePattern = /Include ~\/.ssh\/sealos\/devbox_config/
const includeLine = `Include ${os.homedir()}/.ssh/sealos/devbox_config`

if (includePattern.test(content)) {
return content.replace(includePattern, includeLine)
} else {
return `${includeLine}\n${content}`
}
}

private sshConfigPreProcess() {
Expand Down
16 changes: 12 additions & 4 deletions extensions/ide/vscode/devbox/src/utils/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ import { execa } from 'execa'
// File access permission modification
export const ensureFileAccessPermission = async (path: string) => {
if (os.platform() === 'win32') {
const username = os.userInfo().username
await execa('icacls', [path, '/inheritance:r'])
await execa('icacls', [path, '/grant:r', `${username}:F`])
await execa('icacls', [path, '/remove:g', 'everyone'])
try {
const username = os.userInfo().username
if (!username) {
throw new Error('can not get username')
}
await execa('icacls', [path, '/inheritance:r'])
await execa('icacls', [path, '/grant:r', `${username}:F`])
await execa('icacls', [path, '/remove:g', 'everyone'])
} catch (error) {
console.error('set file access permission failed:', error)
throw new Error(`set file access permission failed: ${error.message}`)
}
} else {
await execa('chmod', ['600', path])
}
Expand Down

0 comments on commit d67b6fe

Please sign in to comment.