Skip to content

Commit 5a37637

Browse files
authored
Fix: Fixed an issue where progress wasn't displayed when extracting archives (#17713)
1 parent 4bce02c commit 5a37637

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
@@ -129,6 +129,36 @@ async Task<bool> DecompressAsyncWithSevenZip(string archiveFilePath, string dest
129129
fsProgress.TotalSize = zipFile.ArchiveFileData.Select(x => (long)x.Size).Sum();
130130
fsProgress.Report();
131131

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

134164
try
@@ -168,35 +198,6 @@ async Task<bool> DecompressAsyncWithSevenZip(string archiveFilePath, string dest
168198
}
169199
}
170200

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

0 commit comments

Comments
 (0)