File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 55 */
66
77import { readFile , writeFile , rename , unlink } from 'fs/promises' ;
8- import { tmpdir } from 'os' ;
98import { join } from 'path' ;
109import type { AuthProfile , AuthProfilesStorage } from '../types.js' ;
1110import {
@@ -64,7 +63,9 @@ async function saveAuthProfilesInternal(storage: AuthProfilesStorage): Promise<v
6463 await ensureDir ( getMcpcHome ( ) ) ;
6564
6665 // Write to a temp file first (atomic operation)
67- const tempFile = join ( tmpdir ( ) , `mcpc-auth-profiles-${ Date . now ( ) } -${ process . pid } .json` ) ;
66+ // Write temp file in the same directory as the target to avoid EXDEV on Linux
67+ // (rename() fails across filesystem boundaries, e.g. /tmp vs ~/.mcpc)
68+ const tempFile = join ( getMcpcHome ( ) , `.profiles-${ Date . now ( ) } -${ process . pid } .tmp` ) ;
6869
6970 try {
7071 const content = JSON . stringify ( storage , null , 2 ) ;
Original file line number Diff line number Diff line change 55 */
66
77import { readFile , writeFile , rename , unlink } from 'fs/promises' ;
8- import { tmpdir } from 'os' ;
98import { join } from 'path' ;
109import type { SessionData , SessionsStorage } from './types.js' ;
1110import {
@@ -62,7 +61,9 @@ async function saveSessionsInternal(storage: SessionsStorage): Promise<void> {
6261 await ensureDir ( getMcpcHome ( ) ) ;
6362
6463 // Write to a temp file first (atomic operation)
65- const tempFile = join ( tmpdir ( ) , `mcpc-sessions-${ Date . now ( ) } -${ process . pid } .json` ) ;
64+ // Write temp file in the same directory as the target to avoid EXDEV on Linux
65+ // (rename() fails across filesystem boundaries, e.g. /tmp vs ~/.mcpc)
66+ const tempFile = join ( getMcpcHome ( ) , `.sessions-${ Date . now ( ) } -${ process . pid } .tmp` ) ;
6667
6768 try {
6869 const content = JSON . stringify ( storage , null , 2 ) ;
You can’t perform that action at this time.
0 commit comments