Skip to content

Commit 7b050b9

Browse files
committed
also check update-ness of library output file
1 parent 4b0fd1d commit 7b050b9

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

kscr-build/KScrBuild.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ private static (ModuleInfo? baseModule, List<Module> exported) ExtractModules(Cm
7272
if (modulesInfo != null)
7373
Log<KScrBuild>.At(LogLevel.Config, $"Found Module root {dir.FullName} as Project {modulesInfo.Project}");
7474
List<Module> exported = new();
75-
foreach (var moduleFile in dir.EnumerateFiles(RuntimeBase.ModuleFile, SearchOption.AllDirectories))
75+
foreach (var moduleFile in dir.EnumerateFiles(RuntimeBase.ModuleFile, SearchOption.AllDirectories)
76+
.Where(file => !Path.GetRelativePath(dir.FullName, file.FullName).StartsWith("build" + Path.DirectorySeparatorChar)))
7677
{
7778
var moduleInfo = JsonSerializer.Deserialize<ModuleInfo>(File.ReadAllText(moduleFile.FullName)) ??
7879
throw new Exception($"Unable to parse {RuntimeBase.ModuleFile} in module {moduleFile.Directory!.FullName}");
@@ -231,7 +232,7 @@ private static void PrintModuleInfo(ModuleInfo module, bool isBaseModule = false
231232
}
232233

233234
public static string Md5Path(FileSystemInfo path) => Path.Combine("build", "checksums",
234-
(path.FullName.Contains("build")
235+
(path.FullName.StartsWith("build" + Path.DirectorySeparatorChar)
235236
? Path.GetRelativePath(Path.Combine(Environment.CurrentDirectory, "build"), path.FullName)
236-
: path.FullName).TrimEnd(Path.DirectorySeparatorChar) + ".md5");
237+
: path.Name).TrimEnd(Path.DirectorySeparatorChar) + ".md5");
237238
}

kscr-build/Module.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ public void SaveToFiles(string dir = null!)
8787
Log<Module>.At(LogLevel.Debug, $"Writing module {Notation} to file {lib.FullName}");
8888
if (lib.Exists)
8989
lib.Delete();
90-
using var zipFile = lib.OpenWrite();
91-
using var archive = new Archive();
92-
using var close = new Container();
90+
var zipFile = lib.OpenWrite();
91+
var archive = new Archive();
92+
var close = new Container(){archive,zipFile};
9393
var moduleFile = new FileInfo(Path.Combine(dir, RuntimeBase.ModuleFile));
9494
Project.SaveToFile(moduleFile.FullName);
9595
foreach (var file in Directory
@@ -110,8 +110,8 @@ public void SaveToFiles(string dir = null!)
110110
}
111111
// ZIP file + cleanup
112112
archive.Save(zipFile);
113-
lib.UpdateMd5(KScrBuild.Md5Path);
114113
close.Dispose();
114+
lib.UpdateMd5(KScrBuild.Md5Path);
115115
}
116116

117117
public override string ToString() =>

0 commit comments

Comments
 (0)