Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private async Task ExecuteWorkflowAsync()
BlackListManager.Instance?.AddBlackFiles(_configInfo.BlackFiles);
BlackListManager.Instance?.AddBlackFileFormats(_configInfo.BlackFormats);
BlackListManager.Instance?.AddSkipDirectorys(_configInfo.SkipDirectorys);

_configInfo.Encoding = GetOption(UpdateOption.Encoding) ?? Encoding.Default;
_configInfo.Format = GetOption(UpdateOption.Format) ?? Format.ZIP;
_configInfo.DownloadTimeOut = GetOption(UpdateOption.DownloadTimeOut) == 0
Expand All @@ -185,7 +185,7 @@ private async Task ExecuteWorkflowAsync()
if (_configInfo.IsMainUpdate)
{
_configInfo.UpdateVersions = upgradeResp.Body.OrderBy(x => x.ReleaseDate).ToList();
_configInfo.LastVersion = _configInfo.UpdateVersions.Last().Version;
_configInfo.LastVersion = mainResp.Body.OrderBy(x => x.ReleaseDate).Last().Version;

var failed = CheckFail(_configInfo.LastVersion);
if (failed) return;
Expand Down
20 changes: 10 additions & 10 deletions src/c#/GeneralUpdate.Common/Compress/ZipCompressionStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void Compress(string sourceDirectoryName
foreach (var toZipFileKey in toZipFileDictionaryList.Keys)
{
if (toZipFileKey == destinationArchiveFileName) continue;

var toZipedFileName = Path.GetFileName(toZipFileKey);
var toDelArchives = new List<ZipArchiveEntry>();
foreach (var zipArchiveEntry in archive.Entries)
Expand Down Expand Up @@ -84,8 +84,8 @@ public void Compress(string sourceDirectoryName
var toDelArchives = new List<ZipArchiveEntry>();
foreach (var zipArchiveEntry in archive.Entries)
{
if (toZipedFileName != null
&& (zipArchiveEntry.FullName.StartsWith(toZipedFileName)|| toZipedFileName.StartsWith(zipArchiveEntry.FullName)))
if (toZipedFileName != null
&& (zipArchiveEntry.FullName.StartsWith(toZipedFileName) || toZipedFileName.StartsWith(zipArchiveEntry.FullName)))
{
toDelArchives.Add(zipArchiveEntry);
}
Expand All @@ -101,13 +101,13 @@ public void Compress(string sourceDirectoryName
}
}
}
catch(Exception exception)
catch (Exception exception)
{
Debug.WriteLine(exception);
throw new Exception($"Failed to compress archive: {exception.Message}");
}
}

/// <summary>
/// Unzip the Zip file and save it to the specified target path folder .
/// </summary>
Expand All @@ -120,7 +120,7 @@ public void Decompress(string zipFilePath, string unZipDir, Encoding encoding)
{
var dirSeparatorChar = Path.DirectorySeparatorChar.ToString();
unZipDir = unZipDir.EndsWith(dirSeparatorChar) ? unZipDir : unZipDir + dirSeparatorChar;

var directoryInfo = new DirectoryInfo(unZipDir);
if (!directoryInfo.Exists)
{
Expand All @@ -138,14 +138,14 @@ public void Decompress(string zipFilePath, string unZipDir, Encoding encoding)
for (int i = 0; i < archive.Entries.Count; i++)
{
var entries = archive.Entries[i];
if (entries.FullName.EndsWith(dirSeparatorChar))
var pattern = $"^{dirSeparatorChar}*";
var entryFilePath = Regex.Replace(entries.FullName.Replace("/", dirSeparatorChar), pattern,
"");
if (entryFilePath.EndsWith(dirSeparatorChar))
{
continue;
}

var pattern = $"^{dirSeparatorChar}*";
var entryFilePath = Regex.Replace(entries.FullName.Replace("/", dirSeparatorChar), pattern,
"");
var filePath = directoryInfo + entryFilePath;
var greatFolder = Directory.GetParent(filePath);
if (greatFolder is not null && !greatFolder.Exists)
Expand Down
Loading