Kaynağa Gözat

Switches to use fs.realpath.native instead of wmic

main
Eric Amodio 4 yıl önce
ebeveyn
işleme
9ffcd2f21a
2 değiştirilmiş dosya ile 8 ekleme ve 22 silme
  1. +7
    -3
      src/git/gitService.ts
  2. +1
    -19
      src/git/shell.ts

+ 7
- 3
src/git/gitService.ts Dosyayı Görüntüle

@ -83,7 +83,7 @@ import {
import { GitUri } from './gitUri';
import { RemoteProvider, RemoteProviderFactory, RemoteProviders, RemoteProviderWithApi } from './remotes/factory';
import { GitReflogParser, GitShortLogParser } from './parsers/parsers';
import { fsExists, getNetworkPathForDrive, isWindows } from './shell';
import { fsExists, isWindows } from './shell';
import { GitRevision, PullRequest, PullRequestDateFormatting } from './models/models';
export * from './gitUri';
@ -2601,8 +2601,12 @@ export class GitService implements Disposable {
const [, letter] = match;
try {
const networkPath = await getNetworkPathForDrive(letter);
if (networkPath != null) {
const networkPath = await new Promise<string>(resolve =>
fs.realpath.native(`${letter}:`, { encoding: 'utf8' }, (err, resolvedPath) =>
resolve(err != null ? undefined : resolvedPath),
),
);
if (networkPath !== undefined) {
return Strings.normalizePath(
repoUri.fsPath.replace(networkPath, `${letter.toLowerCase()}:`),
);

+ 1
- 19
src/git/shell.ts Dosyayı Görüntüle

@ -1,8 +1,7 @@
'use strict';
import { exec, execFile } from 'child_process';
import { execFile } from 'child_process';
import * as fs from 'fs';
import * as paths from 'path';
import { promisify } from 'util';
import * as iconv from 'iconv-lite';
import { Logger } from '../logger';
@ -191,20 +190,3 @@ export function run(
export function fsExists(path: string) {
return new Promise<boolean>(resolve => fs.exists(path, exists => resolve(exists)));
}
const networkDriveRegex = /([A-Z]):\s+(.*?)\s*$/m;
export async function getNetworkPathForDrive(letter: string): Promise<string | undefined> {
const result = await promisify(exec)(
`wmic logicaldisk where 'drivetype=4 and deviceid="${letter}:"' get deviceid,providername`,
{
maxBuffer: 2000 * 1024,
},
);
const match = networkDriveRegex.exec(result.stdout);
if (match == null) return undefined;
const [, , path] = match;
return path;
}

Yükleniyor…
İptal
Kaydet