Skip to content

Commit

Permalink
disable FSW on OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
clemensv committed Sep 5, 2024
1 parent 07e4369 commit 6366a33
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/Microsoft.Azure.Relay.Bridge/Configuration/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ public class Config : IDisposable
{
private const string AzureBridgeName = "azbridge";
RelayConnectionStringBuilder relayConnectionStringBuilder;
#if !_OSX
readonly List<FileSystemWatcher> fileSystemWatchers;
#endif
List<LocalForward> localForward;
List<RemoteForward> remoteForward;

public Config()
{
relayConnectionStringBuilder = new RelayConnectionStringBuilder();
#if !_OSX
fileSystemWatchers = new List<FileSystemWatcher>();
#endif
localForward = new List<LocalForward>();
remoteForward = new List<RemoteForward>();
}
Expand Down Expand Up @@ -481,6 +485,7 @@ public static Config LoadConfig(CommandLineSettings commandLineSettings)
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), $"{azbridge}\\{azbridge}_config.machine.yml");

Config config = LoadConfigFile(machineConfigFileName);
#if !_OSX
Action<string> onchange = (string op) => {
// put this on the thread pool since we want to drain the file watcher queue
_ = Task.Run(() =>
Expand Down Expand Up @@ -517,6 +522,7 @@ public static Config LoadConfig(CommandLineSettings commandLineSettings)
fsw.EnableRaisingEvents = true;
config.fileSystemWatchers.Add(fsw);
}
#endif

if (string.IsNullOrEmpty(commandLineSettings.ConfigFile))
{
Expand All @@ -528,6 +534,7 @@ public static Config LoadConfig(CommandLineSettings commandLineSettings)

Config userConfig = LoadConfigFile(userConfigFileName);
config.Merge(userConfig);
#if !_OSX
if (Directory.Exists(Path.GetDirectoryName(userConfigFileName)))
{
var fsw = new FileSystemWatcher(Path.GetDirectoryName(userConfigFileName), Path.GetFileName(userConfigFileName));
Expand All @@ -537,11 +544,13 @@ public static Config LoadConfig(CommandLineSettings commandLineSettings)
fsw.EnableRaisingEvents = true;
config.fileSystemWatchers.Add(fsw);
}
#endif
}
else
{
Config overrideConfig = LoadConfigFile(commandLineSettings.ConfigFile);
config.Merge(overrideConfig);
#if !_OSX
if (Directory.Exists(Path.GetDirectoryName(commandLineSettings.ConfigFile)))
{
var fsw = new FileSystemWatcher(Path.GetDirectoryName(commandLineSettings.ConfigFile), Path.GetFileName(commandLineSettings.ConfigFile));
Expand All @@ -551,6 +560,7 @@ public static Config LoadConfig(CommandLineSettings commandLineSettings)
fsw.EnableRaisingEvents = true;
config.fileSystemWatchers.Add(fsw);
}
#endif
}

if (commandLineSettings.Option != null)
Expand Down Expand Up @@ -1313,13 +1323,15 @@ protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
#if !_OSX
if (disposing)
{
foreach (var w in fileSystemWatchers)
{
w.Dispose();
}
}
#endif
disposedValue = true;
}
}
Expand Down
5 changes: 3 additions & 2 deletions test/unit/Microsoft.Azure.Relay.Bridge.Tests/ConfigTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,8 @@ public void ConfigSaveLoadFileTest()
File.Delete(configFileName);
}
}

#if !_OSX
[Fact]
public void ConfigLocalForwardTest()
{
Expand Down Expand Up @@ -932,6 +934,5 @@ public void ConfigLocalForwardTest()
}
}
}


#endif
}

Check failure on line 938 in test/unit/Microsoft.Azure.Relay.Bridge.Tests/ConfigTest.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

} expected

0 comments on commit 6366a33

Please sign in to comment.