Beispiel #1
0
        private async Task <bool> Syncronize()
        {
            try
            {
                var settings = SettingsManager.GetSettings();

                if (settings != null)
                {
                    SetStateMessage(State.IndexingRemoteRepository);
                    var remoteRepository = await SynchronizationManager.IndexRemoteRepository(settings.User);

                    if (!remoteRepository.Any())
                    {
                        FollowRequest followRequestWindow =
                            new FollowRequest($"{settings.User},\nplease add {appName} and try again", settings.User, this);
                        followRequestWindow.Show();
                    }
                    else
                    {
                        SetStateMessage(State.IndexingLocalRepository);
                        DirectoryHelper.CreateDirectory(settings.Path);
                        var localRepository = SynchronizationManager.IndexLocalRepository(settings.Path);

                        SetStateMessage(State.SyncronizationInProgress);
                        await SynchronizationManager.SaveFiles(remoteRepository, localRepository, settings.Path);

                        SyncButton.IsEnabled = true;
                    }
                }
                else
                {
                    SyncButton.IsEnabled = true;
                }

                SetStateMessage(State.SyncronizationDone);
            }
            catch (Exception exception)
            {
                logsManager.Log(exception.ToString());
            }

            return(true);
        }