Skip to content

Commit e2b0030

Browse files
authored
Ensure that the core/fundamental directories (e.g. logs, packages) are created up front to directory read/write issues. (#631)
1 parent ef4ce85 commit e2b0030

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/VirtualClient/VirtualClient.Main/CommandBase.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,9 @@ protected virtual IServiceCollection InitializeDependencies(string[] args)
549549
IKeyVaultManager keyVaultManager = new KeyVaultManager();
550550
ApiClientManager apiClientManager = new ApiClientManager(this.ApiPorts);
551551

552+
// Ensure the core/fundamental directories exist.
553+
this.CreateCoreDirectories(platformSpecifics, systemManagement.FileSystem);
554+
552555
// The Virtual Client supports a proxy API interface. When a proxy API is used, all dependencies/blobs will be download
553556
// through the proxy endpoint. All content/files will be uploaded through the proxy endpoint. All telemetry will be uploaded
554557
// the proxy endpoint (with the exception of file logging which remains as-is). This enables Virtual Client to support disconnected
@@ -907,6 +910,29 @@ private static void AddSummaryLogging(List<ILoggerProvider> loggingProviders, st
907910
loggingProviders.Add(summaryLoggerProvider);
908911
}
909912

913+
private void CreateCoreDirectories(PlatformSpecifics platformSpecifics, IFileSystem fileSystem)
914+
{
915+
// Core Directories:
916+
// - logs
917+
// - packages
918+
// - temp
919+
920+
if (!fileSystem.Directory.Exists(platformSpecifics.LogsDirectory))
921+
{
922+
fileSystem.Directory.CreateDirectory(platformSpecifics.LogsDirectory);
923+
}
924+
925+
if (!fileSystem.Directory.Exists(platformSpecifics.PackagesDirectory))
926+
{
927+
fileSystem.Directory.CreateDirectory(platformSpecifics.PackagesDirectory);
928+
}
929+
930+
if (!fileSystem.Directory.Exists(platformSpecifics.TempDirectory))
931+
{
932+
fileSystem.Directory.CreateDirectory(platformSpecifics.TempDirectory);
933+
}
934+
}
935+
910936
private string EvaluatePathReplacements(string path)
911937
{
912938
if (this.pathReplacements == null)

0 commit comments

Comments
 (0)