Skip to content

Commit 2d0a737

Browse files
committed
Fix: Fixed Status Center not showing extraction progress for archives
1 parent 53466f5 commit 2d0a737

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

src/Files.App/Services/Storage/StorageArchiveService.cs

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,36 @@ async Task<bool> DecompressAsyncWithSevenZip(string archiveFilePath, string dest
128128
fsProgress.TotalSize = zipFile.ArchiveFileData.Select(x => (long)x.Size).Sum();
129129
fsProgress.Report();
130130

131+
zipFile.Extracting += (s, e) =>
132+
{
133+
if (fsProgress.TotalSize > 0)
134+
fsProgress.Report(e.BytesProcessed / (double)fsProgress.TotalSize * 100);
135+
};
136+
137+
zipFile.FileExtractionStarted += (s, e) =>
138+
{
139+
if (statusCard.CancellationToken.IsCancellationRequested)
140+
e.Cancel = true;
141+
142+
if (!e.FileInfo.IsDirectory)
143+
{
144+
ThreadingService.ExecuteOnUiThreadAsync(() =>
145+
{
146+
fsProgress.FileName = e.FileInfo.FileName;
147+
fsProgress.Report();
148+
});
149+
}
150+
};
151+
152+
zipFile.FileExtractionFinished += (s, e) =>
153+
{
154+
if (!e.FileInfo.IsDirectory)
155+
{
156+
fsProgress.AddProcessedItemsCount(1);
157+
fsProgress.Report();
158+
}
159+
};
160+
131161
bool isSuccess = false;
132162

133163
try
@@ -166,35 +196,6 @@ async Task<bool> DecompressAsyncWithSevenZip(string archiveFilePath, string dest
166196
}
167197
}
168198

169-
zipFile.Extracting += (s, e) =>
170-
{
171-
if (fsProgress.TotalSize > 0)
172-
fsProgress.Report(e.BytesProcessed / (double)fsProgress.TotalSize * 100);
173-
};
174-
175-
zipFile.FileExtractionStarted += (s, e) =>
176-
{
177-
if (statusCard.CancellationToken.IsCancellationRequested)
178-
e.Cancel = true;
179-
180-
if (!e.FileInfo.IsDirectory)
181-
{
182-
ThreadingService.ExecuteOnUiThreadAsync(() =>
183-
{
184-
fsProgress.FileName = e.FileInfo.FileName;
185-
fsProgress.Report();
186-
});
187-
}
188-
};
189-
190-
zipFile.FileExtractionFinished += (s, e) =>
191-
{
192-
if (!e.FileInfo.IsDirectory)
193-
{
194-
fsProgress.AddProcessedItemsCount(1);
195-
fsProgress.Report();
196-
}
197-
};
198199
return isSuccess;
199200
}
200201

0 commit comments

Comments
 (0)