Skip to content

Commit 0b9655a

Browse files
authored
Merge pull request #12 from cortex-command-community/development
fix: target CCCP 6.0 to correctly validate filepaths in new Mods/Data…
2 parents 1f1e348 + 494531e commit 0b9655a

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

packages/server/src/services/fs.service.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { readdirSync, statSync } from 'fs';
22
import { join, relative } from 'path';
3-
import { moduleDirectoryExtension } from 'shared';
3+
import {
4+
DATA_DIRECTORY,
5+
MOD_DIRECTORY,
6+
moduleDirectoryExtension,
7+
} from 'shared';
48
import { WorkspaceFolder } from 'vscode-languageserver';
5-
import { URI } from 'vscode-uri';
9+
import { URI, Utils } from 'vscode-uri';
610

711
class FileSystemService {
812
public moduleFileList: string[] = [];
@@ -16,11 +20,20 @@ class FileSystemService {
1620
public updateFileList(): void {
1721
this.moduleFileList = [];
1822
this.workspaces.forEach((folder) => {
19-
const workspacePath = URI.parse(folder.uri).fsPath;
20-
const workspaceFileList = this.getAllFiles(workspacePath);
23+
const workspaceUri = URI.parse(folder.uri);
2124

22-
for (const file of workspaceFileList) {
23-
this.moduleFileList.push(relative(workspacePath, file));
25+
const dataPathUri = Utils.joinPath(workspaceUri, DATA_DIRECTORY);
26+
const modsPathUri = Utils.joinPath(workspaceUri, MOD_DIRECTORY);
27+
28+
const workspaceDataFileList = this.getAllFiles(dataPathUri.fsPath);
29+
const workspaceModFileList = this.getAllFiles(modsPathUri.fsPath);
30+
31+
for (const file of workspaceDataFileList) {
32+
this.moduleFileList.push(relative(dataPathUri.fsPath, file));
33+
}
34+
35+
for (const file of workspaceModFileList) {
36+
this.moduleFileList.push(relative(modsPathUri.fsPath, file));
2437
}
2538
});
2639
}

packages/shared/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export * from './lib/Shared';
22

33
export * from './lib/fileExtensions';
4+
5+
export * from './lib/constants';

packages/shared/src/lib/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const DATA_DIRECTORY = 'Data';
2+
export const MOD_DIRECTORY = 'Mods';

0 commit comments

Comments
 (0)