Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 14d13a3

Browse files
committed
Make sure git-lfs is unzipped with the right permissions on mac
1 parent 192d515 commit 14d13a3

File tree

7 files changed

+46
-28
lines changed

7 files changed

+46
-28
lines changed

Diff for: src/GitHub.Api/IO/NiceIO.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,9 @@ public override int GetHashCode()
476476
hash = hash * 23 + _isInitialized.GetHashCode();
477477
hash = hash * 23 + _isRelative.GetHashCode();
478478
foreach (var element in _elements)
479-
hash = hash * 23 + (IsLinux ? element : element.ToUpperInvariant()).GetHashCode();
479+
hash = hash * 23 + (IsUnix ? element : element.ToUpperInvariant()).GetHashCode();
480480
if (_driveLetter != null)
481-
hash = hash * 23 + (IsLinux ? _driveLetter : _driveLetter.ToUpperInvariant()).GetHashCode();
481+
hash = hash * 23 + (IsUnix ? _driveLetter : _driveLetter.ToUpperInvariant()).GetHashCode();
482482
return hash;
483483
}
484484
}
@@ -1087,14 +1087,14 @@ public static IFileSystem FileSystem
10871087
}
10881088
}
10891089

1090-
private static bool? _isLinux;
1091-
internal static bool IsLinux
1090+
private static bool? _isUnix;
1091+
internal static bool IsUnix
10921092
{
10931093
get
10941094
{
1095-
if (!_isLinux.HasValue)
1096-
_isLinux = FileSystem.DirectoryExists("/proc");
1097-
return _isLinux.Value;
1095+
if (!_isUnix.HasValue)
1096+
_isUnix = Environment.OSVersion.Platform == PlatformID.MacOSX || Environment.OSVersion.Platform == PlatformID.Unix;
1097+
return _isUnix.Value;
10981098
}
10991099
}
11001100

@@ -1103,10 +1103,10 @@ private static StringComparison PathStringComparison
11031103
{
11041104
get
11051105
{
1106-
// this is lazily evaluated because IsLinux uses the FileSystem object and that can be set
1106+
// this is lazily evaluated because IsUnix uses the FileSystem object and that can be set
11071107
// after static constructors happen here
11081108
if (!_pathStringComparison.HasValue)
1109-
_pathStringComparison = IsLinux ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
1109+
_pathStringComparison = IsUnix ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
11101110
return _pathStringComparison.Value;
11111111
}
11121112
}
@@ -1165,7 +1165,7 @@ public static NPath Resolve(this NPath path)
11651165
{
11661166
// Add a reference to Mono.Posix with an .rsp file in the Assets folder with the line "-r:Mono.Posix.dll" for this to work
11671167
#if ENABLE_MONO
1168-
if (!path.IsInitialized || !NPath.IsLinux /* nothing to resolve on windows */ || path.IsRelative || !path.FileExists())
1168+
if (!path.IsInitialized || !NPath.IsUnix /* nothing to resolve on windows */ || path.IsRelative || !path.FileExists())
11691169
return path;
11701170
return new NPath(Mono.Unix.UnixPath.GetCompleteRealPath(path.ToString()));
11711171
#else

Diff for: src/GitHub.Api/Installer/ZipHelper.cs

+22-12
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,28 @@ public bool Extract(string archive, string outFolder, CancellationToken cancella
6767
{
6868
Directory.CreateDirectory(directoryName);
6969
}
70-
//#if !WINDOWS
71-
// if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX)
72-
// {
73-
// if (zipEntry.ExternalFileAttributes > 0)
74-
// {
75-
// int fd = Mono.Unix.Native.Syscall.open(fullZipToPath,
76-
// Mono.Unix.Native.OpenFlags.O_CREAT | Mono.Unix.Native.OpenFlags.O_TRUNC,
77-
// (Mono.Unix.Native.FilePermissions)zipEntry.ExternalFileAttributes);
78-
// Mono.Unix.Native.Syscall.close(fd);
79-
// }
80-
// }
81-
//#endif
70+
71+
try
72+
{
73+
if (NPath.IsUnix)
74+
{
75+
if (zipEntry.ExternalFileAttributes == -2115174400)
76+
{
77+
int fd = Mono.Unix.Native.Syscall.open(fullZipToPath,
78+
Mono.Unix.Native.OpenFlags.O_CREAT | Mono.Unix.Native.OpenFlags.O_TRUNC,
79+
Mono.Unix.Native.FilePermissions.S_IRWXU |
80+
Mono.Unix.Native.FilePermissions.S_IRGRP |
81+
Mono.Unix.Native.FilePermissions.S_IXGRP |
82+
Mono.Unix.Native.FilePermissions.S_IROTH |
83+
Mono.Unix.Native.FilePermissions.S_IXOTH);
84+
Mono.Unix.Native.Syscall.close(fd);
85+
}
86+
}
87+
}
88+
catch (Exception ex)
89+
{
90+
LogHelper.Error(ex, "Error setting file attributes in " + fullZipToPath);
91+
}
8292

8393
// Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size
8494
// of the file, but does not waste memory.

Diff for: src/GitHub.Api/PlatformResources/mac/git-lfs.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{"md5":"c78270c2c94a4adce4beeef3010c732e","url":"http://ghfvs-installer.github.com/unity/git/mac/git-lfs.zip","releaseNotes":null,"releaseNotesUrl":null,"message":null,"version":"2.4.0"}
1+
{"md5":"e2941215f99afa99f002e96c0ae70966","url":"http://ghfvs-installer.github.com/unity/git/mac/git-lfs.zip","releaseNotes":null,"releaseNotesUrl":null,"message":null,"version":"2.4.0"}
2+
WARNING: The runtime version supported by this application is unavailable.
3+
Using default runtime: v4.0.30319

Diff for: src/GitHub.Api/PlatformResources/mac/git-lfs.zip

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:d8d924dfef97d579305a485f30ad3866f775b295394be199eb487faca4357672
3-
size 2831355
2+
oid sha256:4e1ea7c1c6b78c05293039c634426760dfc36cedd6a8a8e92ab26809abcf829a
3+
size 2936128

Diff for: src/tests/TestWebServer/TestWebServer.csproj

+4-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@
6363
<None Include="files\unity\git\windows\git.zip">
6464
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
6565
</None>
66-
<None Include="files\unity\git\windows\gitconfig">
66+
<None Include="files\unity\git\mac\git-lfs.json">
67+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
68+
</None>
69+
<None Include="files\unity\git\mac\git-lfs.zip">
6770
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
6871
</None>
6972
<None Include="files\unity\latest.json">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{"md5":"e2941215f99afa99f002e96c0ae70966","url":"http://localhost:50000/unity/git/mac/git-lfs.zip","releaseNotes":null,"releaseNotesUrl":null,"message":null,"version":"2.4.0"}
2+
WARNING: The runtime version supported by this application is unavailable.
3+
Using default runtime: v4.0.30319
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:59a817fa5fa9cbd38eff9422eb576f31e3a225d5be387b292dc827faddfe785b
3-
size 2831355
2+
oid sha256:4e1ea7c1c6b78c05293039c634426760dfc36cedd6a8a8e92ab26809abcf829a
3+
size 2936128

0 commit comments

Comments
 (0)