Ejemplo n.º 1
0
        private async Task LoadStartupDataAsync(CancellationToken cancellationToken)
        {
            logger.Debug("Startup Complete! Loading startup data");

            // There's a race where Syncthing died, and so we kill the API clients and set it to null,
            // but we still end up here, because threading.
            var apiClient = this.apiClient.Value;

            cancellationToken.ThrowIfCancellationRequested();

            var syncthingVersionTask = apiClient.FetchVersionAsync(cancellationToken);
            var systemInfoTask       = apiClient.FetchSystemInfoAsync(cancellationToken);

            await Task.WhenAll(syncthingVersionTask, systemInfoTask);

            this.systemInfo = systemInfoTask.Result;
            var syncthingVersion = syncthingVersionTask.Result;

            this.Version = new SyncthingVersionInformation(syncthingVersion.Version, syncthingVersion.LongVersion);
            this._capabilities.SyncthingVersion = this.Version.ParsedVersion;

            cancellationToken.ThrowIfCancellationRequested();

            await this.LoadConfigDataAsync(this.systemInfo.Tilde, false, cancellationToken);

            cancellationToken.ThrowIfCancellationRequested();

            this.StartedTime  = DateTime.UtcNow;
            this.IsDataLoaded = true;
            this.OnDataLoaded();
        }
Ejemplo n.º 2
0
        private async Task LoadStartupDataAsync(CancellationToken cancellationToken)
        {
            logger.Debug("Startup Complete! Loading startup data");

            // There's a race where Syncthing died, and so we kill the API clients and set it to null,
            // but we still end up here, because threading.
            cancellationToken.ThrowIfCancellationRequested();
            var apiClient = this.apiClient.GetAsserted();

            var syncthingVersionTask = apiClient.FetchVersionAsync();
            var systemInfoTask = apiClient.FetchSystemInfoAsync();

            await Task.WhenAll(syncthingVersionTask, systemInfoTask);

            this.systemInfo = systemInfoTask.Result;
            var syncthingVersion = syncthingVersionTask.Result;

            this.Version = new SyncthingVersionInformation(syncthingVersion.Version, syncthingVersion.LongVersion);
            this._capabilities.SyncthingVersion = this.Version.ParsedVersion;
            
            cancellationToken.ThrowIfCancellationRequested();

            var debugFacilitiesLoadTask = this._debugFacilities.LoadAsync();
            var configDataLoadTask = this.LoadConfigDataAsync(this.systemInfo.Tilde, false, cancellationToken);

            await Task.WhenAll(debugFacilitiesLoadTask, configDataLoadTask);

            cancellationToken.ThrowIfCancellationRequested();
            
            this.StartedTime = DateTime.UtcNow;
            this.IsDataLoaded = true;
            this.OnDataLoaded();
        }