Example #1
0
 /// <summary>
 /// Reads or builds and reads Remote Client & Reference Client & Installed Client File List
 /// </summary>
 /// <returns>awaitable Task</returns>
 public Task Setup()
 {
     return(Task.Run(() =>
     {
         RemoteClient.Setup().Wait();
         ExistingClient.Setup().Wait();
         InstalledClient.Setup().Wait();
         Install().Wait();
         OnCompleted?.Invoke();
     }));
 }
Example #2
0
        /// <summary>
        /// Verify files of the installed client. Undo's every change the user performed, such as edits and restores deleted files.
        /// </summary>
        /// <returns>awaitable task</returns>
        public Task VerifyClient(bool deleteRedundantFiles = false)
        {
            return(Task.Run(() =>
            {
                var fileList = Path.Combine(InstalledClient.Path, "FileList.ini");
                if (File.Exists(fileList))
                {
                    File.Delete(fileList);
                }

                InstalledClient.Setup().Wait();
                InstalledClient.WriteList();

                fileList = Path.Combine(ExistingClient.Path, "FileList.ini");
                if (File.Exists(fileList))
                {
                    File.Delete(fileList);
                }

                ExistingClient.Setup().Wait();
                ExistingClient.WriteList();

                Install().Wait();

                foreach (var checksum in RemoteClient.Checksums)
                {
                    InstalledClient.Checksums.TryRemove(checksum.Key, out string ignored);
                }
                if (deleteRedundantFiles)
                {
                    OnFileChange?.Invoke($"Removing {InstalledClient.Checksums.Count} Orphaned Files");
                    foreach (var checksum in InstalledClient.Checksums)
                    {
                        var path = Path.Combine(InstalledClient.Path, checksum.Key);
                        if (File.Exists(path))
                        {
                            File.Delete(path);
                        }
                    }
                    InstalledClient.Checksums.Clear();
                    foreach (var checksum in RemoteClient.Checksums)
                    {
                        InstalledClient.Checksums.AddOrUpdate(checksum.Key, checksum.Value);
                    }
                    InstalledClient.WriteList();
                }

                OnCompleted?.Invoke();
            }));
        }