Skip to content

Commit 99e8a95

Browse files
committed
Convert to using Properties
1 parent d9c0dfe commit 99e8a95

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ void ExecuteWithAbi (string [] supportedAbis, string apkInputPath, string apkOut
140140
refresh = false;
141141
}
142142
using (var apk = new ZipArchiveEx (apkOutputPath, File.Exists (apkOutputPath) ? FileMode.Open : FileMode.Create )) {
143+
if (int.TryParse (ZipFlushFilesLimit, out int flushFilesLimit)) {
144+
apk.ZipFlushFilesLimit = flushFilesLimit;
145+
}
146+
if (int.TryParse (ZipFlushSizeLimit, out int flushSizeLimit)) {
147+
apk.ZipFlushSizeLimit = flushSizeLimit;
148+
}
143149
if (refresh) {
144150
for (long i = 0; i < apk.Archive.EntryCount; i++) {
145151
ZipEntry e = apk.Archive.ReadEntry ((ulong) i);
@@ -294,12 +300,6 @@ void ExecuteWithAbi (string [] supportedAbis, string apkInputPath, string apkOut
294300

295301
public override bool RunTask ()
296302
{
297-
if (int.TryParse (ZipFlushFilesLimit, out int flushFilesLimit)) {
298-
ZipArchiveEx.ZipFlushFilesLimit = flushFilesLimit;
299-
}
300-
if (int.TryParse (ZipFlushSizeLimit, out int flushSizeLimit)) {
301-
ZipArchiveEx.ZipFlushSizeLimit = flushSizeLimit;
302-
}
303303
Aot.TryGetSequencePointsMode (AndroidSequencePointsMode, out sequencePointsMode);
304304

305305
var outputFiles = new List<string> ();

src/Xamarin.Android.Build.Tasks/Utilities/ZipArchiveEx.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ namespace Xamarin.Android.Tasks
88
public class ZipArchiveEx : IDisposable
99
{
1010

11-
public static int ZipFlushSizeLimit = 100 * 1024 * 1024;
12-
public static int ZipFlushFilesLimit = 512;
11+
const int DEFAULT_FLUSH_SIZE_LIMIT = 100 * 1024 * 1024;
12+
const int DEFAULT_FLUSH_FILES_LIMIT = 512;
1313

1414
ZipArchive zip;
1515
string archive;
@@ -24,6 +24,9 @@ public ZipArchive Archive {
2424

2525
public bool CreateDirectoriesInZip { get; set; } = true;
2626

27+
public int ZipFlushSizeLimit { get; set; } = DEFAULT_FLUSH_SIZE_LIMIT;
28+
public int ZipFlushFilesLimit { get; set; } = DEFAULT_FLUSH_FILES_LIMIT;
29+
2730
public ZipArchiveEx (string archive) : this (archive, FileMode.CreateNew)
2831
{
2932
}
@@ -65,7 +68,7 @@ void AddFileAndFlush (string filename, long fileLength, string archiveFileName,
6568
{
6669
filesWrittenTotalSize += fileLength;
6770
zip.AddFile (filename, archiveFileName, compressionMethod: compressionMethod);
68-
if ((filesWrittenTotalSize >= ZipArchiveEx.ZipFlushSizeLimit || filesWrittenTotalCount >= ZipArchiveEx.ZipFlushFilesLimit) && AutoFlush) {
71+
if ((filesWrittenTotalSize >= ZipFlushSizeLimit || filesWrittenTotalCount >= ZipFlushFilesLimit) && AutoFlush) {
6972
Flush ();
7073
}
7174
}
@@ -80,7 +83,7 @@ public void AddEntryAndFlush (byte[] data, string archiveFileName)
8083
{
8184
filesWrittenTotalSize += data.Length;
8285
zip.AddEntry (data, archiveFileName);
83-
if ((filesWrittenTotalSize >= ZipArchiveEx.ZipFlushSizeLimit || filesWrittenTotalCount >= ZipArchiveEx.ZipFlushFilesLimit) && AutoFlush) {
86+
if ((filesWrittenTotalSize >= ZipFlushSizeLimit || filesWrittenTotalCount >= ZipFlushFilesLimit) && AutoFlush) {
8487
Flush ();
8588
}
8689
}
@@ -89,7 +92,7 @@ public void AddEntryAndFlush (string archiveFileName, Stream data, CompressionMe
8992
{
9093
filesWrittenTotalSize += data.Length;
9194
zip.AddEntry (archiveFileName, data, method);
92-
if ((filesWrittenTotalSize >= ZipArchiveEx.ZipFlushSizeLimit || filesWrittenTotalCount >= ZipArchiveEx.ZipFlushFilesLimit) && AutoFlush) {
95+
if ((filesWrittenTotalSize >= ZipFlushSizeLimit || filesWrittenTotalCount >= ZipFlushFilesLimit) && AutoFlush) {
9396
Flush ();
9497
}
9598
}

0 commit comments

Comments
 (0)