Example #1
0
        /// <summary>
        /// Returns a list containing the server files' names that are not present locally.
        /// </summary>
        private static List <string> CalculateMissingContent()
        {
            List <string> missingFiles = new List <string>();

            foreach (string file in ServerMetadata.Keys)
            {
                if (!FileSystemExplorer.FileExists(file))
                {
                    missingFiles.Add(file);
                }
            }
            return(missingFiles);
        }
 private static IEnumerable <Bundle> GetAllBundles()
 {
     if (RuntimeInfo.RunningOnWindows)
     {
         return(RegistryQuery.GetInstalledBundles());
     }
     else if (RuntimeInfo.RunningOnOSX)
     {
         return(FileSystemExplorer.GetInstalledBundles());
     }
     else
     {
         throw new OperatingSystemNotSupportedException();
     }
 }
 /// <summary>
 /// Invokes the <c>FileSystemExplorer</c> to try to download and write a list of specific files (content) to the disk.
 /// isMissingContent is true if the method is invoked as a mean to download missing content, or false if to download outdated content.
 /// After the downloads and writes are completed, the local metadata is refreshed.
 /// </summary>
 private static void DownloadContent(int step, List <string> content, bool isMissingContent)
 {
     LogDownloadingEvent(content.Count, isMissingContent);
     for (int i = 0; i < content.Count; i++)
     {
         Utils.Log(BW, content[i], ProgressiveWidgetsEnum.Label.DownloadLogger); Utils.Log(BW, string.Format(PatcherEngineResources.FILE_COUNT, i + 1, content.Count, Convert.ToInt32((i + 1f) / content.Count * 100)), ProgressiveWidgetsEnum.Label.FileCountLogger);
         // The expected hash of the file to be downloaded is already saved in the ServerMetadata.
         FileSystemExplorer.FetchFile(BW, content[i], PatchDirectory + content[i], ServerMetadata[content[i]].Hash);
         Utils.Progress(BW, Convert.ToInt32(GetCurrentStepProgress(step) + (i + 1f) / content.Count * (1f / Pipeline.Length * 100)), ProgressiveWidgetsEnum.ProgressBar.WholeProgressBar);
     }
     // Give time to AntiVirus for it to delete or tamper any of the recently downloaded files.
     Thread.Sleep(EngineConfigs.MS_TO_WAIT_FOR_AV_FALSE_POSITIVES);
     GenerateLocalMetadata();
     Utils.Log(BW, string.Empty, ProgressiveWidgetsEnum.Label.FileCountLogger);
     Utils.Log(BW, string.Empty, ProgressiveWidgetsEnum.Label.DownloadSpeedLogger);
 }
Example #4
0
 public static void Execute()
 {
     if (RuntimeInfo.RunningOnWindows)
     {
         Execute(
             RegistryQuery.GetInstalledBundles(),
             Windows.SupportedBundleTypeConfigs.SupportedBundleTypes);
     }
     else if (RuntimeInfo.RunningOnOSX)
     {
         Execute(
             FileSystemExplorer.GetInstalledBundles(),
             MacOs.SupportedBundleTypeConfigs.SupportedBundleTypes);
     }
     else
     {
         throw new OperatingSystemNotSupportedException();
     }
 }
Example #5
0
 /// <summary>
 /// Asks the FileSystemExplorer for a fresh copy of the local metadata performed in a concurrent way.
 /// </summary>
 private static void GenerateLocalMetadata()
 {
     // The local metadata refreshed is based only on the contents available in the server metadata.
     // Do it with a concurrency level equal to half the number of processors.
     LocalMetadata = FileSystemExplorer.GenerateLocalMetadata(ServerMetadata.Keys.ToArray(), Hasher, Math.Max(1, Environment.ProcessorCount / 2));
 }