Esempio n. 1
0
        public void CreateCloudDrive_WhereGatewayIsNotRegistered_Throws()
        {
            _fixture.SetupTryGetAsyncCloudGatewayForSchema(_schema, false);
            _fixture.SetupTryGetCloudGatewayForSchema(_schema, false);
            var sut = new CloudDriveFactory();// { GatewayManager = _fixture.GetGatewayManager() };

            sut.CreateCloudDrive(_schema, _user, _root, new CloudDriveParameters());
        }
Esempio n. 2
0
        private CloudDriveFactory InitializeCloudDriveFactory(string libPath)
        {
            CompositionInitializer.Preload(typeof(CloudFS.Interface.Composition.ICloudGateway));
            CompositionInitializer.Initialize(new[] { typeof(Program).Assembly }, libPath, "IgorSoft.CloudFS.Gateways.*.dll");
            var factory = new CloudDriveFactory();

            CompositionInitializer.SatisfyImports(factory);
            return(factory);
        }
Esempio n. 3
0
        public void CreateCloudDrive_WhereAsyncGatewayIsRegistered_Succeeds()
        {
            _fixture.SetupTryGetAsyncCloudGatewayForSchema(_schema);

            var sut = new CloudDriveFactory();// { GatewayManager = _fixture.GetGatewayManager() };

            using (var result = sut.CreateCloudDrive(_schema, _user, _root, new CloudDriveParameters())) {
                Assert.IsInstanceOfType(result, typeof(AsyncCloudDrive), "Unexpected result type");
            }
        }
Esempio n. 4
0
        MountSession MountDrive()
        {
            var cancellation = new CancellationTokenSource();
            var factory      = new CloudDriveFactory();
            var drive        = factory.CreateCloudDrive(
                _config.Schema,
                _username,
                _config.Root,
                new CloudDriveParameters()
            {
                ApiKey        = _config.Locator,
                EncryptionKey = _config.Secret,
                Logger        = _logger,
                Cancellation  = cancellation.Token,
                Parameters    = _config.GetParameters()
            }
                );

            if (!drive.TryAuthenticate())
            {
                var displayRoot = drive.DisplayRoot;
                drive.Dispose();
                _logger.Warn($"Authentication failed for drive '{displayRoot}'");
            }

            var operations = new CloudOperations(drive, _logger);

            // HACK: handle non-unique parameter set of DokanOperations.Mount() by explicitely specifying AllocationUnitSize and SectorSize
            var runner = Task.Run(() => operations.Mount(_config.Root,
                                                         DokanOptions.NetworkDrive | DokanOptions.MountManager | DokanOptions.CurrentSession,
                                                         threadCount: 5,
                                                         121,
                                                         TimeSpan.FromSeconds(_config.Timeout != 0 ? _config.Timeout : 20),
                                                         null, 512, 512),
                                  cancellation.Token);

            var session = new MountSession(_config.Root[0], runner, cancellation);

            var driveInfo = new DriveInfo(_config.Root);

            while (!driveInfo.IsReady)
            {
                Thread.Sleep(10);
            }
            _logger.Info($"Drive '{drive.DisplayRoot}' mounted successfully.");

            return(session);
        }
Esempio n. 5
0
        public void CreateCloudDrive_WhereGatewayIsRegistered_Succeeds()
        {
            const string schema = "test";

            fixture.SetupTryGetAsyncCloudGatewayForSchema(schema, false);
            fixture.SetupTryGetCloudGatewayForSchema(schema);

            var sut = new CloudDriveFactory()
            {
                GatewayManager = fixture.GetGatewayManager()
            };

            using (var result = sut.CreateCloudDrive(schema, user, root, new CloudDriveParameters())) {
                Assert.IsInstanceOfType(result, typeof(CloudDrive), "Unexpected result type");
            }
        }
Esempio n. 6
0
        internal static void Main(string[] args)
        {
            var mountSection = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).Sections[MountSection.Name] as MountSection;

            if (mountSection == null)
            {
                throw new ConfigurationErrorsException("Mount configuration missing");
            }

            CompositionInitializer.Preload(typeof(IgorSoft.CloudFS.Interface.Composition.ICloudGateway));
            CompositionInitializer.Initialize(mountSection.LibPath, "IgorSoft.CloudFS.Gateways.*.dll");
            var factory = new CloudDriveFactory();

            CompositionInitializer.SatisfyImports(factory);

            try {
                var logger = new LogFactory().GetCurrentClassLogger();
                using (var tokenSource = new CancellationTokenSource()) {
                    var tasks = new List <Task>();
                    foreach (var drive in mountSection.Drives.Cast <DriveElement>())
                    {
                        var operations = new CloudOperations(factory.CreateCloudDrive(drive.Schema, drive.UserName, drive.Root, new CloudDriveParameters()
                        {
                            EncryptionKey = drive.EncryptionKey, Parameters = drive.GetParameters()
                        }), logger);

                        // HACK: handle non-unique parameter set of DokanOperations.Mount() by explicitely specifying AllocationUnitSize and SectorSize
                        tasks.Add(Task.Run(() => operations.Mount(drive.Root, DokanOptions.RemovableDrive | DokanOptions.MountManager | DokanOptions.CurrentSession, mountSection.Threads, 1100, TimeSpan.FromSeconds(drive.Timeout != 0 ? drive.Timeout : 20), null, 512, 512), tokenSource.Token));

                        var driveInfo = new DriveInfo(drive.Root);
                        while (!driveInfo.IsReady)
                        {
                            Thread.Sleep(10);
                        }
                    }

                    Console.ReadKey(true);

                    tokenSource.Cancel();
                }
            } finally {
                foreach (var drive in mountSection.Drives.Cast <DriveElement>())
                {
                    Dokan.Unmount(drive.Root[0]);
                }
            }
        }
Esempio n. 7
0
        public void CreateCloudDrive_WhereGatewayManagerIsNotInitialized_Throws()
        {
            var sut = new CloudDriveFactory();

            sut.CreateCloudDrive(schema, user, root, null);
        }