mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-24 11:46:32 +00:00
fixed issue when checking if a sketch is temp
convert all windows drive letters to lower case. [ATL-380] Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
aa2bed8d39
commit
bc4c3e04f5
@ -3,3 +3,7 @@ export const naturalCompare: (left: string, right: string) => number = require('
|
||||
export function notEmpty(arg: string | undefined | null): arg is string {
|
||||
return !!arg;
|
||||
}
|
||||
|
||||
export function firstToLowerCase(what: string): string {
|
||||
return what.charAt(0).toLowerCase() + what.slice(1);
|
||||
}
|
||||
|
@ -6,15 +6,19 @@ import { ncp } from 'ncp';
|
||||
import { Stats } from 'fs';
|
||||
import * as fs from './fs-extra';
|
||||
import URI from '@theia/core/lib/common/uri';
|
||||
import { isWindows } from '@theia/core/lib/common/os';
|
||||
import { FileUri, BackendApplicationContribution } from '@theia/core/lib/node';
|
||||
import { ConfigService } from '../common/protocol/config-service';
|
||||
import { SketchesService, Sketch } from '../common/protocol/sketches-service';
|
||||
import { firstToLowerCase } from '../common/utils';
|
||||
|
||||
|
||||
// As currently implemented on Linux,
|
||||
// the maximum number of symbolic links that will be followed while resolving a pathname is 40
|
||||
const MAX_FILESYSTEM_DEPTH = 40;
|
||||
|
||||
const WIN32_DRIVE_REGEXP = /^[a-zA-Z]:\\/;
|
||||
|
||||
// TODO: `fs`: use async API
|
||||
@injectable()
|
||||
export class SketchesServiceImpl implements SketchesService, BackendApplicationContribution {
|
||||
@ -330,8 +334,19 @@ void loop() {
|
||||
}
|
||||
|
||||
async isTemp(sketch: Sketch): Promise<boolean> {
|
||||
const sketchPath = FileUri.fsPath(sketch.uri);
|
||||
return sketchPath.indexOf('.arduinoProIDE-unsaved') !== -1 && sketchPath.startsWith(os.tmpdir());
|
||||
let sketchPath = FileUri.fsPath(sketch.uri);
|
||||
let temp = os.tmpdir();
|
||||
// Note: VS Code URI normalizes the drive letter. `C:` will be converted into `c:`.
|
||||
// https://github.com/Microsoft/vscode/issues/68325#issuecomment-462239992
|
||||
if (isWindows) {
|
||||
if (WIN32_DRIVE_REGEXP.exec(sketchPath)) {
|
||||
sketchPath = firstToLowerCase(sketchPath);
|
||||
}
|
||||
if (WIN32_DRIVE_REGEXP.exec(temp)) {
|
||||
temp = firstToLowerCase(temp);
|
||||
}
|
||||
}
|
||||
return sketchPath.indexOf('.arduinoProIDE-unsaved') !== -1 && sketchPath.startsWith(temp);
|
||||
}
|
||||
|
||||
async copy(sketch: Sketch, { destinationUri }: { destinationUri: string }): Promise<string> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user