Skip to content

Commit 18f3f52

Browse files
committed
Add support for empty components, output dependencies to metadata files again
1 parent dfe02ba commit 18f3f52

File tree

2 files changed

+36
-27
lines changed

2 files changed

+36
-27
lines changed

FlashpointInstaller/src/Forms/Operate.cs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private async void Operation_Load(object sender, EventArgs e)
5454
foreach (var component in markedComponents)
5555
{
5656
workingComponent = component;
57-
stream = await downloader.DownloadFileTaskAsync(component.URL);
57+
if (component.Size > 0) stream = await downloader.DownloadFileTaskAsync(component.URL);
5858

5959
if (cancelStatus != 0) return;
6060

@@ -136,26 +136,30 @@ private void OnDownloadFileCompleted(object sender, System.ComponentModel.AsyncC
136136

137137
private void ExtractComponents()
138138
{
139+
string rootPath = FPM.DestinationPath;
140+
string infoPath = Path.Combine(rootPath, "Components");
141+
string infoFile = Path.Combine(infoPath, $"{workingComponent.ID}.txt");
142+
143+
Directory.CreateDirectory(infoPath);
144+
145+
using (TextWriter writer = File.CreateText(infoFile))
146+
{
147+
string[] header = new List<string>
148+
{ workingComponent.Hash, $"{workingComponent.Size}" }.Concat(workingComponent.Depends).ToArray();
149+
150+
writer.WriteLine(string.Join(" ", header));
151+
}
152+
153+
if (workingComponent.Size == 0) return;
154+
139155
using (archive = ZipArchive.Open(stream))
140156
{
141157
using (reader = archive.ExtractAllEntries())
142158
{
143159
long extractedSize = 0;
144160
long totalSize = archive.TotalUncompressSize;
145-
146-
string rootPath = FPM.DestinationPath;
161+
147162
string destPath = Path.Combine(rootPath, workingComponent.Path.Replace('/', '\\'));
148-
string infoPath = Path.Combine(rootPath, "Components");
149-
string infoFile = Path.Combine(infoPath, $"{workingComponent.ID}.txt");
150-
151-
Directory.CreateDirectory(infoPath);
152-
153-
using (TextWriter writer = File.CreateText(infoFile))
154-
{
155-
string[] header = new[] { workingComponent.Hash, workingComponent.Size.ToString() }.ToArray();
156-
157-
writer.WriteLine(string.Join(" ", header));
158-
}
159163

160164
while (cancelStatus == 0 && reader.MoveToNextEntry())
161165
{

FlashpointManager/src/Forms/Operate.cs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private async void Operation_Load(object sender, EventArgs e)
7878
foreach (var component in addedComponents)
7979
{
8080
workingComponent = component;
81-
stream = await downloader.DownloadFileTaskAsync(component.URL);
81+
if (component.Size > 0) stream = await downloader.DownloadFileTaskAsync(component.URL);
8282

8383
if (cancelStatus != 0) return;
8484

@@ -157,25 +157,30 @@ private void OnDownloadFileCompleted(object sender, System.ComponentModel.AsyncC
157157

158158
private void ExtractComponents()
159159
{
160+
string rootPath = Path.Combine(FPM.SourcePath, "Temp");
161+
string infoPath = Path.Combine(rootPath, "Components");
162+
string infoFile = Path.Combine(infoPath, $"{workingComponent.ID}.txt");
163+
164+
Directory.CreateDirectory(infoPath);
165+
166+
using (TextWriter writer = File.CreateText(infoFile))
167+
{
168+
string[] header = new List<string>
169+
{ workingComponent.Hash, $"{workingComponent.Size}" }.Concat(workingComponent.Depends).ToArray();
170+
171+
writer.WriteLine(string.Join(" ", header));
172+
}
173+
174+
if (workingComponent.Size == 0) return;
175+
160176
using (archive = ZipArchive.Open(stream))
161177
{
162178
using (reader = archive.ExtractAllEntries())
163179
{
164180
long extractedSize = 0;
165181
long totalSize = archive.TotalUncompressSize;
166182

167-
string destPath = Path.Combine(FPM.SourcePath, "Temp", workingComponent.Path.Replace('/', '\\'));
168-
string infoPath = Path.Combine(FPM.SourcePath, "Temp", "Components");
169-
string infoFile = Path.Combine(infoPath, $"{workingComponent.ID}.txt");
170-
171-
Directory.CreateDirectory(infoPath);
172-
173-
using (TextWriter writer = File.CreateText(infoFile))
174-
{
175-
string[] header = new[] { workingComponent.Hash, workingComponent.Size.ToString() }.ToArray();
176-
177-
writer.WriteLine(string.Join(" ", header));
178-
}
183+
string destPath = Path.Combine(rootPath, workingComponent.Path.Replace('/', '\\'));
179184

180185
while (cancelStatus == 0 && reader.MoveToNextEntry())
181186
{

0 commit comments

Comments
 (0)