Пример #1
0
        private void ValidateMapping(List <RemotePathMapping> existing, RemotePathMapping mapping)
        {
            if (mapping.Host.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Invalid Host");
            }

            var remotePath = new OsPath(mapping.RemotePath);
            var localPath  = new OsPath(mapping.LocalPath);

            if (remotePath.IsEmpty)
            {
                throw new ArgumentException("Invalid RemotePath");
            }

            if (localPath.IsEmpty || !localPath.IsRooted)
            {
                throw new ArgumentException("Invalid LocalPath");
            }

            if (!_diskProvider.FolderExists(localPath.FullPath))
            {
                throw new DirectoryNotFoundException("Can't add mount point directory that doesn't exist.");
            }

            if (existing.Exists(r => r.Host == mapping.Host && r.RemotePath == mapping.RemotePath))
            {
                throw new InvalidOperationException("RemotePath already mounted.");
            }
        }
Пример #2
0
        public RemotePathMapping Update(RemotePathMapping mapping)
        {
            var existing = All().Where(v => v.Id != mapping.Id).ToList();

            ValidateMapping(existing, mapping);

            var result = _remotePathMappingRepository.Update(mapping);

            _cache.Clear();

            return(result);
        }
Пример #3
0
        public RemotePathMapping Update(RemotePathMapping mapping)
        {
            var existing = All().Where(v => v.Id != mapping.Id).ToList();

            ValidateMapping(existing, mapping);

            var result = _remotePathMappingRepository.Update(mapping);

            _cache.Clear();

            return result;
        }
Пример #4
0
        public RemotePathMapping Add(RemotePathMapping mapping)
        {
            mapping.LocalPath  = new OsPath(mapping.LocalPath).AsDirectory().FullPath;
            mapping.RemotePath = new OsPath(mapping.RemotePath).AsDirectory().FullPath;

            var all = All();

            ValidateMapping(all, mapping);

            var result = _remotePathMappingRepository.Insert(mapping);

            _cache.Clear();

            return(result);
        }
Пример #5
0
        public RemotePathMapping Add(RemotePathMapping mapping)
        {
            mapping.LocalPath = new OsPath(mapping.LocalPath).AsDirectory().FullPath;
            mapping.RemotePath = new OsPath(mapping.RemotePath).AsDirectory().FullPath;

            var all = All();

            ValidateMapping(all, mapping);

            var result = _remotePathMappingRepository.Insert(mapping);

            _cache.Clear();

            return result;
        }
Пример #6
0
        public RemotePathMapping Add(RemotePathMapping mapping)
        {
            mapping.LocalPath  = CleanPath(mapping.LocalPath);
            mapping.RemotePath = CleanPath(mapping.RemotePath);

            var all = All();

            ValidateMapping(all, mapping);

            var result = _remotePathMappingRepository.Insert(mapping);

            _cache.Clear();

            return(result);
        }
Пример #7
0
        private void ValidateMapping(List<RemotePathMapping> existing, RemotePathMapping mapping)
        {
            if (mapping.Host.IsNullOrWhiteSpace())
            {
                throw new ArgumentException("Invalid Host");
            }

            var remotePath = new OsPath(mapping.RemotePath);
            var localPath = new OsPath(mapping.LocalPath);

            if (remotePath.IsEmpty)
            {
                throw new ArgumentException("Invalid RemotePath");
            }

            if (localPath.IsEmpty || !localPath.IsRooted)
            {
                throw new ArgumentException("Invalid LocalPath");
            }

            if (!_diskProvider.FolderExists(localPath.FullPath))
            {
                throw new DirectoryNotFoundException("Can't add mount point directory that doesn't exist.");
            }

            if (existing.Exists(r => r.Host == mapping.Host && r.RemotePath == mapping.RemotePath))
            {
                throw new InvalidOperationException("RemotePath already mounted.");
            }
        }