示例#1
0
        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;
            }
        }
示例#2
0
 public BobDisk(PhysicalId physicalId, MountPath mountPath, BobPath bobPath, string diskNameInBob)
 {
     PhysicalId    = physicalId ?? throw new ArgumentNullException(nameof(physicalId));
     MountPath     = mountPath;
     BobPath       = bobPath ?? throw new ArgumentNullException(nameof(bobPath));
     DiskNameInBob = diskNameInBob;
 }
示例#3
0
        private static BobDisk FindInfo(Disk bobDisk, IList <PhysicalDisk> physicalDisks)
        {
            var path = new BobPath(bobDisk.Path);
            var disk = physicalDisks.Where(d => d.Volumes.Any(v => v.ContainsPath(path)))
                       .OrderByDescending(d => d.Volumes.Where(v => v.ContainsPath(path)).Max(v => v.MountPath.Value.Length))
                       .FirstOrDefault();

            if (disk != null)
            {
                var volume = disk.Volumes.Where(v => v.ContainsPath(path)).OrderByDescending(v => v.MountPath.Value.Length).First();
                return(new BobDisk(volume.PhysicalId, volume.MountPath.Value, path, bobDisk.Name));
            }
            return(null);
        }
示例#4
0
 public bool ContainsPath(BobPath path)
 {
     return(MountPath != null && path.StartsWith(MountPath.Value));
 }