Skip to content

Commit cf342d6

Browse files
committed
Merge branch 'develop'
2 parents 9063c01 + ca59c05 commit cf342d6

File tree

8 files changed

+19
-136
lines changed

8 files changed

+19
-136
lines changed

src/Tetrifact.Core/ArchiveProgressInfo.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ public class ArchiveProgressInfo
3232
/// <summary>
3333
///
3434
/// </summary>
35-
public decimal FileCopyProgress { get ; set;}
36-
37-
public decimal CompressProgress { get; set; }
38-
39-
public decimal CombinedPercent { get; set; }
35+
public decimal PercentProgress { get ; set;}
4036

4137
public long ProjectedSize { get; set; }
4238

src/Tetrifact.Core/ArchiveService.cs

+8-7
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ private async Task ArchiveDotNetZip(string packageId, string archivePathTemp)
203203

204204
_log.LogInformation($"Starting archive generation for package \"{packageId}\". Type: .Net compression. Rate : {_settings.ArchiveCompression}.");
205205

206+
// static progress handler, this calculates percentage from tick events returned by zip
206207
ProgressEvent progressEvent = (long delta, long localTotal) => {
207208
progress += delta;
208209
int thisPercent = Percent.Calc(progress, total);
@@ -218,7 +219,7 @@ private async Task ArchiveDotNetZip(string packageId, string archivePathTemp)
218219
};
219220

220221
progress.State = PackageArchiveCreationStates.ArchiveGenerating;
221-
progress.CombinedPercent = percent;
222+
progress.PercentProgress = percent;
222223
_cache.Set(progressCacheKey, progress);
223224
}
224225
};
@@ -228,7 +229,7 @@ private async Task ArchiveDotNetZip(string packageId, string archivePathTemp)
228229
{
229230
// Note : no null check here, we assume DoesPackageExist test above would catch invalid names
230231
Manifest manifest = _indexReader.GetManifest(packageId);
231-
total = manifest.SizeOnDisk;
232+
total = manifest.Size;
232233

233234
using (ZipArchive archive = new ZipArchive(zipStream, ZipArchiveMode.Create, true))
234235
{
@@ -248,10 +249,10 @@ private async Task ArchiveDotNetZip(string packageId, string archivePathTemp)
248249
{
249250
ZipArchiveEntry storageArchiveEntry = storageArchive.Entries[0];
250251
using (var storageArchiveStream = storageArchiveEntry.Open())
251-
{
252-
StreamProgressCopy copy = new StreamProgressCopy(storageArchiveStream, zipStream, copyStepSize);
253-
copy.OnProgress += progressEvent;
254-
await copy.Work();
252+
{
253+
StreamProgressCopy copy = new StreamProgressCopy(storageArchiveStream, zipEntryStream, copyStepSize);
254+
copy.OnProgress += progressEvent;
255+
await copy.Work();
255256
}
256257
}
257258
}
@@ -263,7 +264,7 @@ private async Task ArchiveDotNetZip(string packageId, string archivePathTemp)
263264

264265
using (Stream fileStream = fileLookup.Content)
265266
{
266-
StreamProgressCopy copy = new StreamProgressCopy(fileStream,zipStream, copyStepSize);
267+
StreamProgressCopy copy = new StreamProgressCopy(fileStream, zipEntryStream, copyStepSize);
267268
copy.OnProgress += progressEvent;
268269
await copy.Work();
269270
}

src/Tetrifact.Core/Percent.cs

+8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ public class Percent
1111
/// <returns></returns>
1212
public static int Calc(decimal first, decimal second)
1313
{
14+
// overflow check
15+
if (second == 0)
16+
return 0;
17+
1418
decimal p = first / second;
1519
return (int)System.Math.Round((decimal)(p * 100), 0);
1620
}
@@ -23,6 +27,10 @@ public static int Calc(decimal first, decimal second)
2327
/// <returns></returns>
2428
public static int Calc(double first, double second)
2529
{
30+
// overflow check
31+
if (second == 0)
32+
return 0;
33+
2634
double p = first / second;
2735
return (int)System.Math.Round((double)(p * 100), 0);
2836
}

src/Tetrifact.Core/PruneService.cs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Linq;
5-
using System.Text;
65

76
namespace Tetrifact.Core
87
{

src/Tetrifact.Web/Core/Daemons/ArchiveStatusChecker.cs

-121
This file was deleted.

src/Tetrifact.Web/Startup.cs

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public void ConfigureServices(IServiceCollection services)
7777
services.AddTransient<ICron, PruneCron>();
7878
services.AddTransient<ICron, CleanerCron>();
7979
services.AddTransient<ICron, ArchiveGenerator>();
80-
services.AddTransient<ICron, ArchiveStatusChecker>();
8180

8281
// ignore error, how else are we going to get an instaace of settings from this piece of crap Microsoft IOC framework?
8382
ISettingsProvider settingsProvider = services.BuildServiceProvider().GetRequiredService<ISettingsProvider>();

src/Tetrifact.Web/Views/Shared/ArchiveProgress.cshtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
}
3333

3434
<text>
35-
@(Math.Round(Model.CombinedPercent, 0))% complete
35+
@(Math.Round(Model.PercentProgress, 0))% complete
3636
</text>
3737
}
3838

utils/upload/wipe.py

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
item_path = os.path.join(work_dir, filename)
3232

3333
try:
34+
print(f'Attempting to remove {item_path}')
3435

3536
if os.path.isfile(item_path):
3637
os.unlink(item_path)

0 commit comments

Comments
 (0)