Skip to content

Fix: Fixed an issue where it sometimes failed to extract an archive #12379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/Files.App/Helpers/ZipHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static class ZipHelpers
{
private static async Task<SevenZipExtractor?> GetZipFile(BaseStorageFile archive, string password = "")
{
return await Filesystem.FilesystemTasks.Wrap(async () =>
return await FilesystemTasks.Wrap(async () =>
{
var arch = new SevenZipExtractor(await archive.OpenStreamForReadAsync(), password);
return arch?.ArchiveFileData is null ? null : arch; // Force load archive (1665013614u)
Expand All @@ -39,7 +39,7 @@ public static async Task ExtractArchive(BaseStorageFile archive, BaseStorageFold
using SevenZipExtractor? zipFile = await GetZipFile(archive, password);
if (zipFile is null)
return;
//zipFile.IsStreamOwner = true;

var directoryEntries = new List<ArchiveFileInfo>();
var fileEntries = new List<ArchiveFileInfo>();
foreach (ArchiveFileInfo entry in zipFile.ArchiveFileData)
Expand Down Expand Up @@ -91,6 +91,7 @@ public static async Task ExtractArchive(BaseStorageFile archive, BaseStorageFold
byte[] buffer = new byte[4096];
int entriesAmount = fileEntries.Count;
int entriesFinished = 0;
var minimumTime = new DateTime(1);

FileSystemProgress fsProgress = new(progress, true, Shared.Enums.FileSystemStatusCode.InProgress, entriesAmount);
fsProgress.Report();
Expand Down Expand Up @@ -119,10 +120,10 @@ public static async Task ExtractArchive(BaseStorageFile archive, BaseStorageFold
return; // TODO: handle error
}
}

_ = new FileInfo(filePath)
{
CreationTime = entry.CreationTime < entry.LastWriteTime ? entry.CreationTime : entry.LastWriteTime,
CreationTime = entry.CreationTime > minimumTime && entry.CreationTime < entry.LastWriteTime ? entry.CreationTime : entry.LastWriteTime,
LastWriteTime = entry.LastWriteTime,
};

Expand Down