Skip to content

Commit

Permalink
avoid I/O process frequency during export process.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyhfish committed Oct 19, 2020
1 parent 4e657a8 commit 76369ba
Showing 1 changed file with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,29 @@ public override void ExportData(ExportImportJob exportJob, ExportDto exportDto)
return;
}

foreach (var file in skinPackageFiles)
using (var zipArchive = CompressionUtil.OpenCreate(packagesZipFile))
{
var exportPackage = this.GenerateExportPackage(file);
if (exportPackage != null)
foreach (var file in skinPackageFiles)
{
this.Repository.CreateItem(exportPackage, null);
totalPackagesExported += 1;
var folderOffset = Path.GetDirectoryName(file)?.Length + 1;
var exportPackage = this.GenerateExportPackage(file);
if (exportPackage != null)
{
this.Repository.CreateItem(exportPackage, null);
totalPackagesExported += 1;
var folderOffset = Path.GetDirectoryName(file)?.Length + 1;

CompressionUtil.AddFileToArchive(file, packagesZipFile, folderOffset.GetValueOrDefault(0));
}
CompressionUtil.AddFileToArchive(zipArchive, file, folderOffset.GetValueOrDefault(0));
}

this.CheckPoint.ProcessedItems++;
this.CheckPoint.Progress = this.CheckPoint.ProcessedItems * 100.0 / totalPackages;
currentIndex++;
this.CheckPoint.ProcessedItems++;
this.CheckPoint.Progress = this.CheckPoint.ProcessedItems * 100.0 / totalPackages;
currentIndex++;

// After every 10 items, call the checkpoint stage. This is to avoid too many frequent updates to DB.
if (currentIndex % 10 == 0 && this.CheckPointStageCallback(this))
{
return;
// After every 10 items, call the checkpoint stage. This is to avoid too many frequent updates to DB.
if (currentIndex % 10 == 0 && this.CheckPointStageCallback(this))
{
return;
}
}
}

Expand Down

0 comments on commit 76369ba

Please sign in to comment.