Skip to content

Commit

Permalink
Merge pull request #87 from yangxuilyx/master
Browse files Browse the repository at this point in the history
following issues are fixed
  • Loading branch information
JusterZhu authored Jan 14, 2025
2 parents a1b8451 + 937e215 commit bf8ede6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,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 @@ -184,7 +184,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

0 comments on commit bf8ede6

Please sign in to comment.