Skip to content

Commit d9ba064

Browse files
committed
fixing env var setting
1 parent c98cff6 commit d9ba064

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/Azure.Functions.Cli/Helpers/ZipHelper.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ public static class ZipHelper
1616
{
1717
public static async Task<Stream> GetAppZipFile(string functionAppRoot, bool buildNativeDeps, BuildOption buildOption, bool noBuild, GitIgnoreParser ignoreParser = null, string additionalPackages = null, bool ignoreDotNetCheck = false)
1818
{
19+
// temporarily provide an escape hatch to use gozip in case there are bugs in the dotnet implementation
20+
bool useGoZip = EnvironmentHelper.GetEnvironmentVariableAsBool(Constants.UseGoZip);
21+
1922
var gitIgnorePath = Path.Combine(functionAppRoot, Constants.FuncIgnoreFile);
2023
if (ignoreParser == null && FileSystemHelpers.FileExists(gitIgnorePath))
2124
{
@@ -45,9 +48,6 @@ public static async Task<Stream> GetAppZipFile(string functionAppRoot, bool buil
4548
}
4649
else if (GlobalCoreToolsSettings.CurrentWorkerRuntime == WorkerRuntime.dotnet && buildOption == BuildOption.Remote)
4750
{
48-
// temporarily provide an escape hatch to use gozip in case there are bugs in the dotnet implementation
49-
bool useGoZip = EnvironmentHelper.GetEnvironmentVariableAsBool(Constants.UseGoZip);
50-
5151
// Remote build for dotnet does not require bin and obj folders. They will be generated during the oryx build
5252
return await CreateZip(FileSystemHelpers.GetLocalFiles(functionAppRoot, ignoreParser, false, new string[] { "bin", "obj" }), functionAppRoot, Enumerable.Empty<string>(), useGoZip);
5353
}
@@ -57,7 +57,7 @@ public static async Task<Stream> GetAppZipFile(string functionAppRoot, bool buil
5757
IEnumerable<string> executables = !string.IsNullOrEmpty(customHandler)
5858
? new[] { customHandler }
5959
: Enumerable.Empty<string>();
60-
return await CreateZip(FileSystemHelpers.GetLocalFiles(functionAppRoot, ignoreParser, false), functionAppRoot, executables);
60+
return await CreateZip(FileSystemHelpers.GetLocalFiles(functionAppRoot, ignoreParser, false), functionAppRoot, executables, useGoZip);
6161
}
6262
}
6363

@@ -67,6 +67,7 @@ public static async Task<Stream> CreateZip(IEnumerable<string> files, string roo
6767
{
6868
if (GoZipExists(out string goZipLocation))
6969
{
70+
ColoredConsole.WriteLine(DarkYellow("Using gozip for packaging."));
7071
var zipFilePath = Path.GetTempFileName();
7172
return await CreateGoZip(files, rootPath, zipFilePath, goZipLocation, executables);
7273
}
@@ -126,15 +127,17 @@ public static Stream CreateDotNetZip(IEnumerable<string> files, string rootPath,
126127
}
127128

128129
// In order to properly mount and/or unzip this in Azure, we need to create the zip as if it were
129-
// Unix so that the correct file permissions set above are applied. To do this, we walk through the stream
130-
// and update the "created by" field to 3, which indicates it was created by Unix.
130+
// Unix so that the correct file permissions set above are applied. To do this, we walk backwards
131+
// through the stream and update the "created by" field to 3, which indicates it was created by Unix.
131132
if (OperatingSystem.IsWindows())
132133
{
133134
memStream.Seek(0, SeekOrigin.End);
134135

135136
// Update the file header in the zip file for every file to indicate that it was created by Unix
136137
while (SeekBackwardsToSignature(memStream, centralDirectorySignature))
137138
{
139+
// The field we need to set is 5 bytes from the beginning of the signature. Set it,
140+
// then move back to the previous location so we can continue.
138141
memStream.Seek(5, SeekOrigin.Current);
139142
memStream.WriteByte(CreatedByUnix);
140143
memStream.Seek(-6, SeekOrigin.Current);

0 commit comments

Comments
 (0)