public async Task PrepareBobPath(BobPath bobPath) { try { string path = bobPath.Path; if (Directory.Exists(path)) { var subDirs = Directory.GetDirectories(path); foreach (var subdir in subDirs) { logger.LogInformation($"Removing {bobPath}"); Directory.Delete(path, true); } } Directory.CreateDirectory(path); await processInvoker.SetDirPermissionsAndOwner(path, configuration.BobDirPermissions, configuration.BobDirOwner); logger.LogInformation($"Created {bobPath}"); } catch (Exception) { logger.LogError($"Failed to prepare path {bobPath}"); throw; } }
public async Task MountVolume(Volume volume, BobApiClient bobApiClient) { if (volume.IsMounted && !volume.IsReadOnly) { logger.LogDebug($"{volume} is already mounted"); return; } if (!volume.Mountable) { logger.LogDebug($"{volume} can't be mounted"); return; } var mountPath = neededInfoStorage.FindMountPath(volume); if (mountPath != null) { var path = mountPath?.Path; if (!Directory.Exists(path)) { await processInvoker.InvokeSudoProcess("mkdir", path); } if (await TryCleanPreviousData(volume, bobApiClient, mountPath.Value) && !volume.IsMounted) { logger.LogInformation($"Mounting {volume} to {mountPath}"); await processInvoker.InvokeSudoProcess("mount", volume.DevPath.Path, path); await processInvoker.SetDirPermissionsAndOwner(path, configuration.MountPointPermissions, configuration.MountPointOwner); logger.LogInformation($"Successfully mounted {volume} to {mountPath}"); } } else { logger.LogInformation($"No mount path found for {volume}"); } }
private async Task CreateDir(string path) { logger.LogInformation($"Creating dir {path}"); System.IO.Directory.CreateDirectory(path); await processInvoker.SetDirPermissionsAndOwner(path, configuration.BobDirPermissions, configuration.BobDirOwner); }