Skip to content

Commit

Permalink
Revert "Added code to clean up the temp directory that pyright create…
Browse files Browse the repository at this point in the history
…s when determining whether the file system is case sensitive. This addresses #4142."

This reverts commit c5d1cfc.
  • Loading branch information
msfterictraut committed Nov 5, 2022
1 parent c5d1cfc commit 8daeee2
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 34 deletions.
1 change: 0 additions & 1 deletion packages/pyright-internal/src/common/fileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export interface TmpfileOptions {
export interface FileSystem {
existsSync(path: string): boolean;
mkdirSync(path: string, options?: MkDirOptions): void;
rmdirSync(path: string): void;
chdir(path: string): void;
readdirEntriesSync(path: string): fs.Dirent[];
readdirSync(path: string): string[];
Expand Down
26 changes: 5 additions & 21 deletions packages/pyright-internal/src/common/pathUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -940,18 +940,15 @@ export function isFileSystemCaseSensitive(fs: FileSystem) {
}

export function isFileSystemCaseSensitiveInternal(fs: FileSystem) {
let filePath: string | undefined;
let tempDirPath: string | undefined;

let filePath: string | undefined = undefined;
try {
// Make unique file name.
let name: string;
let mangledFilePath: string;
do {
name = `${randomBytesHex(21)}-a`;
tempDirPath = fs.tmpdir();
filePath = path.join(tempDirPath, name);
mangledFilePath = path.join(tempDirPath, name.toUpperCase());
filePath = path.join(fs.tmpdir(), name);
mangledFilePath = path.join(fs.tmpdir(), name.toUpperCase());
} while (fs.existsSync(filePath) || fs.existsSync(mangledFilePath));

fs.writeFileSync(filePath, '', 'utf8');
Expand All @@ -962,21 +959,8 @@ export function isFileSystemCaseSensitiveInternal(fs: FileSystem) {
return false;
} finally {
if (filePath) {
try {
// Remove temp file.
fs.unlinkSync(filePath);
} catch (e: any) {
// Ignore exception.
}
}

if (tempDirPath) {
try {
// Remove temp directory.
fs.rmdirSync(tempDirPath);
} catch (e: any) {
// Ignore exception.
}
// remove temp file created
fs.unlinkSync(filePath);
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions packages/pyright-internal/src/common/realFileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,6 @@ class RealFileSystem implements FileSystem {
yarnFS.mkdirSync(path, options);
}

rmdirSync(path: string) {
yarnFS.rmdirSync(path);
}

chdir(path: string) {
process.chdir(path);
}
Expand Down
4 changes: 0 additions & 4 deletions packages/pyright-internal/src/pyrightFileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ export class PyrightFileSystem
this._realFS.mkdirSync(path, options);
}

override rmdirSync(path: string): void {
this._realFS.rmdirSync(path);
}

override chdir(path: string): void {
this._realFS.chdir(path);
}
Expand Down
4 changes: 0 additions & 4 deletions packages/pyright-internal/src/readonlyAugmentedFileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ export class ReadOnlyAugmentedFileSystem implements FileSystem {
throw new Error('Operation is not allowed.');
}

rmdirSync(path: string): void {
throw new Error('Operation is not allowed.');
}

chdir(path: string): void {
throw new Error('Operation is not allowed.');
}
Expand Down

0 comments on commit 8daeee2

Please sign in to comment.