Skip to content

Commit 2ed8c78

Browse files
committed
fix: target CCCP 6.0 to correctly validate filepaths in new Mods/Data folders
1 parent 1f1e348 commit 2ed8c78

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

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

Lines changed: 20 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[] = [];
@@ -14,13 +18,23 @@ class FileSystemService {
1418
}
1519

1620
public updateFileList(): void {
21+
console.log('Updating file list');
1722
this.moduleFileList = [];
1823
this.workspaces.forEach((folder) => {
19-
const workspacePath = URI.parse(folder.uri).fsPath;
20-
const workspaceFileList = this.getAllFiles(workspacePath);
24+
const workspaceUri = URI.parse(folder.uri);
2125

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

packages/server/src/validations/validateFilePath.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ export function validateFilePaths(textDocument: TextDocument): Diagnostic[] {
7676
}
7777

7878
function checkIfPathExists(filePath: string): boolean {
79+
console.log('checking if file exists: ', filePath);
80+
console.log(
81+
'fileSystemService.moduleFileList',
82+
fileSystemService.moduleFileList.slice(0, 5)
83+
);
84+
7985
if (fileSystemService.moduleFileList.includes(filePath)) {
8086
return true;
8187
}

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';
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)