Skip to content

Commit 677978b

Browse files
committed
Cleanup update method
1 parent 39224c7 commit 677978b

File tree

1 file changed

+21
-29
lines changed

1 file changed

+21
-29
lines changed

src/EasySign/Bundle.cs

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -742,31 +742,11 @@ public void Update()
742742

743743
using (ZipArchive zip = GetZipArchive(ZipArchiveMode.Update))
744744
{
745-
if (_pendingForRemove.Count > 0)
746-
{
747-
Logger.LogDebug("Deleting pending files from the bundle");
748-
}
749-
750-
ZipArchiveEntry? tempEntry;
751-
foreach (string entryName in _pendingForRemove)
752-
{
753-
if ((tempEntry = zip.GetEntry(entryName)) != null)
754-
{
755-
Logger.LogDebug("Deleting entry: {name}", entryName);
756-
tempEntry.Delete();
757-
}
758-
else
759-
{
760-
Logger.LogWarning("Entry {name} not found in the bundle", entryName);
761-
}
762-
}
763-
764-
if (Updating != null)
765-
{
766-
Logger.LogDebug("Invoking Updating event");
767-
}
768-
745+
Logger.LogDebug("Invoking Updating event");
769746
Updating?.Invoke(zip);
747+
748+
Logger.LogDebug("Processing pending files");
749+
ProcessPendingFiles(zip);
770750

771751
Logger.LogDebug("Writing manifest to the bundle");
772752
byte[] manifestData = GetManifestData();
@@ -775,17 +755,29 @@ public void Update()
775755
Logger.LogDebug("Writing signatures to the bundle");
776756
byte[] signatureData = Export(Signatures, SourceGenerationSignaturesContext.Default);
777757
WriteEntry(zip, ".signatures.ec", signatureData);
758+
}
759+
}
778760

779-
if (_pendingForAdd.Count > 0)
761+
private void ProcessPendingFiles(ZipArchive zip)
762+
{
763+
ZipArchiveEntry? tempEntry;
764+
foreach (string entryName in _pendingForRemove)
765+
{
766+
if ((tempEntry = zip.GetEntry(entryName)) != null)
780767
{
781-
Logger.LogDebug("Writing pending files to the bundle");
768+
Logger.LogDebug("Deleting entry: {name}", entryName);
769+
tempEntry.Delete();
782770
}
783-
784-
foreach (KeyValuePair<string, byte[]> newFile in _pendingForAdd)
771+
else
785772
{
786-
WriteEntry(zip, newFile.Key, newFile.Value);
773+
Logger.LogWarning("Entry {name} not found in the bundle", entryName);
787774
}
788775
}
776+
777+
foreach (KeyValuePair<string, byte[]> newFile in _pendingForAdd)
778+
{
779+
WriteEntry(zip, newFile.Key, newFile.Value);
780+
}
789781
}
790782

791783
/// <summary>

0 commit comments

Comments
 (0)