Skip to content

Commit ede63f6

Browse files
author
Alberto Iannaccone
committed
improve check of read-only files
1 parent b701a0a commit ede63f6

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

arduino-ide-extension/src/common/protocol/sketches-service-client-impl.ts

+18-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ import { FrontendApplicationContribution } from '@theia/core/lib/browser/fronten
1111
import { Sketch, SketchesService } from '../../common/protocol';
1212
import { ConfigService } from './config-service';
1313
import { SketchContainer } from './sketches-service';
14+
import * as path from 'path';
15+
import {
16+
ARDUINO_CLOUD_FOLDER,
17+
REMOTE_SKETCHBOOK_FOLDER,
18+
} from '../../browser/utils/constants';
1419

15-
const READ_ONLY_FILES = [
16-
'thingProperties.h',
17-
'thingsProperties.h',
18-
'sketch.json',
19-
];
20+
const READ_ONLY_FILES = ['sketch.json'];
21+
const READ_ONLY_FILES_REMOTE = ['thingProperties.h', 'thingsProperties.h'];
2022

2123
@injectable()
2224
export class SketchesServiceClientImpl
@@ -178,7 +180,17 @@ export class SketchesServiceClientImpl
178180
if (toCheck.scheme === 'user-storage') {
179181
return false;
180182
}
181-
if (READ_ONLY_FILES.includes(toCheck?.path?.base)) {
183+
184+
const isCloudSketch = toCheck
185+
.toString()
186+
.includes(path.join(REMOTE_SKETCHBOOK_FOLDER, ARDUINO_CLOUD_FOLDER));
187+
188+
const filesToCheck = [
189+
...READ_ONLY_FILES,
190+
...(isCloudSketch ? READ_ONLY_FILES_REMOTE : []),
191+
];
192+
193+
if (filesToCheck.includes(toCheck?.path?.base)) {
182194
return true;
183195
}
184196
const readOnly = !this.workspaceService

0 commit comments

Comments
 (0)