Skip to content

Commit f271d31

Browse files
committed
server resources packaging
1 parent 08eb49f commit f271d31

File tree

3 files changed

+32
-25
lines changed

3 files changed

+32
-25
lines changed

Robust.Packaging/RobustClientPackaging.cs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,6 @@ public static async Task WriteClientResources(
3535
.ToHashSet();
3636

3737
await RobustSharedPackaging.DoResourceCopy(Path.Combine(contentDir, "Resources"), pass, ignoreSet, cancel: cancel);
38-
39-
var manifestPath = Path.Combine(contentDir, "Resources", "manifest.yml");
40-
var manifest = ResourceManifestData.LoadFromFile(manifestPath); // load from disk no VFS
41-
42-
if (manifest.ModularResources != null)
43-
{
44-
foreach (var (vfsPath,diskName) in manifest.ModularResources)
45-
{
46-
var modPath = Path.Combine(contentDir, diskName);
47-
if (!Directory.Exists(modPath))
48-
continue;
49-
var files = Directory.EnumerateFiles(modPath, "*", SearchOption.AllDirectories);
50-
foreach (var file in files)
51-
{
52-
var filename = Path.GetFileName(file);
53-
if (ignoreSet.Contains(filename)) continue;
54-
var relative = Path.GetRelativePath(modPath, file);
55-
var zipRoot = vfsPath.TrimStart('/');
56-
var targetPath = Path.Combine(zipRoot, relative).Replace('\\', '/');
57-
await using var stream = File.OpenRead(file);
58-
pass.InjectFileFromDisk(targetPath, file);
59-
}
60-
}
61-
}
38+
await RobustSharedPackaging.DoModularResourceCopy(contentDir, pass, ignoreSet);
6239
}
6340
}

Robust.Packaging/RobustServerPackaging.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,7 @@ await RobustSharedPackaging.DoResourceCopy(
4040
pass,
4141
ignoreSet,
4242
cancel: cancel);
43+
44+
await RobustSharedPackaging.DoModularResourceCopy(contentDir, pass, ignoreSet);
4345
}
4446
}

Robust.Packaging/RobustSharedPackaging.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Robust.Packaging.AssetProcessing;
2+
using Robust.Shared.ContentPack;
23

34
namespace Robust.Packaging;
45

@@ -82,10 +83,37 @@ public static Task DoResourceCopy(
8283
return Task.CompletedTask;
8384
}
8485

85-
private static void CopyDirIntoZip(string directory, string basePath, AssetPass pass)
86+
public static Task DoModularResourceCopy(string contentDir, AssetPass pass, HashSet<string> ignoreSet)
87+
{
88+
var manifestPath = Path.Combine(contentDir, "Resources", "manifest.yml");
89+
var manifest = ResourceManifestData.LoadFromFile(manifestPath);
90+
if (manifest.ModularResources == null) return Task.CompletedTask;
91+
92+
foreach (var (vfsPath, diskName) in manifest.ModularResources)
93+
{
94+
var modPath = Path.Combine(contentDir, diskName);
95+
if (!Directory.Exists(modPath))
96+
continue;
97+
98+
var zipRoot = vfsPath.TrimStart('/');
99+
CopyDirIntoZip(modPath, zipRoot, pass, ignoreSet);
100+
}
101+
102+
return Task.CompletedTask;
103+
}
104+
105+
private static void CopyDirIntoZip(
106+
string directory,
107+
string basePath,
108+
AssetPass pass,
109+
IReadOnlySet<string>? ignoreSet = null)
86110
{
87111
foreach (var file in Directory.EnumerateFiles(directory, "*.*", SearchOption.AllDirectories))
88112
{
113+
var filename = Path.GetFileName(file);
114+
if (ignoreSet != null && ignoreSet.Contains(filename))
115+
continue;
116+
89117
var relPath = Path.GetRelativePath(directory, file);
90118
var zipPath = $"{basePath}/{relPath}";
91119

0 commit comments

Comments
 (0)