Skip to content

Commit 6291021

Browse files
authored
Merge pull request #24 from KSP2Community/dev
Fix bug when rebuilding cache
2 parents 3956b99 + 0cc75c7 commit 6291021

4 files changed

Lines changed: 53 additions & 21 deletions

File tree

.github/workflows/on-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
permissions: write-all
1111
steps:
1212
- name: Check out repository
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414

1515
- name: Install jq
1616
uses: dcarbone/install-jq-action@v2.1.0
@@ -54,7 +54,7 @@ jobs:
5454
dotnet nuget push "$nupkg_path" -s https://nuget.spacewarp.org/v3/index.json -k ${{ secrets.NUGET_SERVER_KEY }}
5555
5656
- name: Upload Zip
57-
uses: actions/upload-release-asset@v1.0.1
57+
uses: shogo82148/actions-upload-release-asset@v1.7.2
5858
env:
5959
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6060
with:
-131 Bytes
Binary file not shown.

plugin_template/swinfo.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
2-
"spec": "1.3",
2+
"spec": "2.0",
33
"mod_id": "PatchManager",
44
"author": "KSP2 Community",
55
"name": "Patch Manager",
66
"description": "A mod for generic patching needs similar to KSP 1's Module Manager.",
77
"source": "https://github.com/KSP2Community/PatchManager",
8-
"version": "0.7.0",
8+
"version": "0.7.1",
99
"version_check": "https://raw.githubusercontent.com/KSP2Community/PatchManager/main/plugin_template/swinfo.json",
1010
"ksp2_version": {
11-
"min": "0.1.5",
11+
"min": "0.2.0",
1212
"max": "*"
1313
},
1414
"dependencies": [
1515
{
1616
"id": "com.github.x606.spacewarp",
1717
"version": {
18-
"min": "1.5.0",
18+
"min": "1.7.0",
1919
"max": "*"
2020
}
2121
}

src/PatchManager.Core/CoreModule.cs

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,30 +87,62 @@ public override void Init()
8787
/// <inheritdoc />
8888
public override void PreLoad()
8989
{
90+
var gameDataModsExists = Directory.Exists(Path.Combine(Paths.GameRootPath, "GameData/Mods"));
91+
9092
// Go here instead so that the static constructor recognizes everything
9193
var disabledPlugins = File.ReadAllText(Path.Combine(Paths.BepInExRootPath, "disabled_plugins.cfg"))
9294
.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
9395

9496
var modFolders = Directory.GetDirectories(Paths.PluginPath, "*", SearchOption.AllDirectories)
95-
.Where(dir => ShouldLoad(disabledPlugins, Path.Combine(dir, "swinfo.json"))).Select(x =>
96-
(Folder: x,
97-
Info: JsonConvert.DeserializeObject<ModInfo>(File.ReadAllText(Path.Combine(x, "swinfo.json")))))
97+
.Where(dir => ShouldLoad(disabledPlugins, Path.Combine(dir, "swinfo.json")))
98+
.Select(x => (
99+
Folder: x,
100+
Info: JsonConvert.DeserializeObject<ModInfo>(File.ReadAllText(Path.Combine(x, "swinfo.json")))
101+
))
98102
.ToList();
99-
modFolders.AddRange(Directory
100-
.GetDirectories(Path.Combine(Paths.GameRootPath, "GameData/Mods"), "*", SearchOption.AllDirectories)
101-
.Where(dir => ShouldLoad(disabledPlugins, Path.Combine(dir, "swinfo.json"))).Select(x =>
102-
(Folder: x,
103-
Info: JsonConvert.DeserializeObject<ModInfo>(File.ReadAllText(Path.Combine(x, "swinfo.json"))))));
103+
104+
if (gameDataModsExists)
105+
{
106+
modFolders.AddRange(
107+
Directory
108+
.GetDirectories(Path.Combine(Paths.GameRootPath, "GameData/Mods"), "*", SearchOption.AllDirectories)
109+
.Where(dir => ShouldLoad(disabledPlugins, Path.Combine(dir, "swinfo.json")))
110+
.Select(x => (
111+
Folder: x,
112+
Info: JsonConvert.DeserializeObject<ModInfo>(File.ReadAllText(Path.Combine(x, "swinfo.json")))
113+
)));
114+
}
115+
104116
var gameRoot = new DirectoryInfo(Paths.GameRootPath);
105117

106-
var standalonePatches = Directory.EnumerateFiles(Path.Combine(Paths.GameRootPath, "GameData/Mods"), "*.patch",
107-
SearchOption.AllDirectories)
108-
.Where(x => NoSwinfo(new FileInfo(x).Directory, gameRoot)).Select(x => new FileInfo(x)).ToList();
109-
standalonePatches.AddRange(Directory.EnumerateFiles(Paths.PluginPath, "*.patch", SearchOption.AllDirectories)
110-
.Where(x => NoSwinfo(new FileInfo(x).Directory, gameRoot)).Select(x => new FileInfo(x)));
118+
var standalonePatches = Directory.EnumerateFiles(
119+
Paths.PluginPath,
120+
"*.patch",
121+
SearchOption.AllDirectories
122+
)
123+
.Where(x => NoSwinfo(new FileInfo(x).Directory, gameRoot))
124+
.Select(x => new FileInfo(x))
125+
.ToList();
126+
127+
if (gameDataModsExists)
128+
{
129+
standalonePatches.AddRange(
130+
Directory.EnumerateFiles(
131+
Path.Combine(Paths.GameRootPath, "GameData/Mods"),
132+
"*.patch",
133+
SearchOption.AllDirectories
134+
)
135+
.Where(x => NoSwinfo(new FileInfo(x).Directory, gameRoot))
136+
.Select(x => new FileInfo(x))
137+
);
138+
}
139+
140+
PatchingManager.GenerateUniverse(standalonePatches.Select(x =>
141+
x.Directory!.FullName
142+
.MakeRelativePathTo(gameRoot.FullName)
143+
.Replace("\\", "-")
144+
).ToHashSet());
111145

112-
PatchingManager.GenerateUniverse(standalonePatches
113-
.Select(x => x.Directory!.FullName.MakeRelativePathTo(gameRoot.FullName).Replace("\\","-")).ToHashSet());
114146
foreach (var modFolder in modFolders)
115147
{
116148
Logging.LogInfo($"Loading patchers from {modFolder.Folder}");

0 commit comments

Comments
 (0)