public VirtualDriveWrapper(IFSProvider provider) { virtualDrive = new VirtualDrive(provider) { OnMount = () => { Mounted?.Invoke(mountLetter); }, OnUnmount = () => { Unmounted?.Invoke(mountLetter); } }; }
public OLD_KohteetController(BFContext context, IFSProvider fsProvider) : base(context, fsProvider, "Kohde") { }
public VirtualDrive(IFSProvider provider) { this.provider = provider; }
private async Task <char> Mount(bool interactiveAuth = true) { try { Instance.OnAuthUpdated = this; var authenticated = await Authenticate(Instance, MountCancellation.Token, interactiveAuth); if (!authenticated) { Log.ErrorTrace("Authentication failed"); throw new InvalidOperationException("Authentication failed"); } var origProv = new FSProvider(instance, ProviderStatisticsUpdated) { VolumeName = CloudInfo.Name, CachePath = Environment.ExpandEnvironmentVariables(Properties.Settings.Default.CacheFolder), SmallFilesCacheSize = Properties.Settings.Default.SmallFilesCacheLimit * (1 << 20), SmallFileSizeLimit = Properties.Settings.Default.SmallFileSizeLimit * (1 << 20) }; var rfProv = new RootFolderFSProvider(origProv); await rfProv.SetRootFolder(CloudInfo.RootFolder); Provider = rfProv; var cloudDrive = new VirtualDriveWrapper(Provider); var mountedEvent = new TaskCompletionSource <char>(); cloudDrive.Mounted = letter => { mountedEvent.SetResult(letter); }; NotifyMount(); var task = Task.Factory.StartNew( () => { try { cloudDrive.Mount(CloudInfo.DriveLetter, CloudInfo.ReadOnly); unmountingEvent.Set(); } catch (InvalidOperationException) { Log.Warn($"Drive letter {CloudInfo.DriveLetter} is already used"); Exception lastException = null; var wasMounted = false; foreach (var letter in VirtualDriveWrapper.GetFreeDriveLettes()) { try { cloudDrive.Mount(letter, CloudInfo.ReadOnly); unmountingEvent.Set(); Instance.Dispose(); instance = null; wasMounted = true; break; } catch (InvalidOperationException ex) { lastException = ex; Log.Warn($"Drive letter {letter} is already used"); } } if (!wasMounted) { var message = "Could not find free letter"; if (lastException?.InnerException != null) { message = lastException.InnerException.Message; } mountedEvent.SetException(new InvalidOperationException(message)); } } catch (Exception ex) { mountedEvent.SetException(ex); } }, TaskCreationOptions.LongRunning); return(await mountedEvent.Task); } finally { NotifyMount(); } }
protected FSQueryController(BFContext context, IFSProvider fsRepository, string repositoryName) : base(context) { this.FSRepository = fsRepository; this.RepositoryName = repositoryName; }
public OLD_KayttajatController(BFContext context, IFSProvider fsProvider) : base(context, fsProvider, "Kayttaja") { }
public OLD_PalveluPaketitController(BFContext context, IFSProvider fsProvider) : base(context, fsProvider, "PalveluPaketti") { }
public RootFolderFSProvider(IFSProvider provider) { this.provider = provider; }