Esempio n. 1
0
        public CrawlPlan(LocalManifest localManifest, RemoteManifest remoteManifest, RemoteDataAccess dao)
        {
            Debug.Assert (localManifest != null);
            Debug.Assert (remoteManifest != null);
            Debug.Assert (dao != null);

            this.dao = dao;

            // Clone the local manifest, because we need to make changes to this copy
            BuildCrawlPlan (localManifest.Clone (), remoteManifest);
        }
Esempio n. 2
0
        protected override void OnDoWork(DoWorkEventArgs e)
        {
            base.OnDoWork(e);
            LocalManifest  = FileUtil.ReadManifest(_manifestPath);
            RemoteManifest = FileUtil.ReadManifest(LocalManifest.ReleaseUrl + "/" + Manifest.ManifestFileName);


            if (LocalManifest.CompareTo(RemoteManifest) != 0)
            {
                HasNewVersion = true;
                if (!string.IsNullOrEmpty(_tempDir))
                {
                    if (!Directory.Exists(_tempDir))
                    {
                        Directory.CreateDirectory(_tempDir);
                    }
                    RemoteManifest.SaveManifest(Path.Combine(_tempDir, Manifest.ManifestFileName));
                    //download update files silently
                    var loader = new Downloader(LocalManifest, RemoteManifest, _tempDir);
                    loader.RunWorkerAsync();
                }
            }
        }
Esempio n. 3
0
        void BuildCrawlPlan(LocalManifest localManifest, RemoteManifest remoteManifest)
        {
            Log.Debug ("Building crawl plan");

            foreach (RemoteManifestEntry remoteEntry in remoteManifest)
            {
                PartialCrawlCommand newCommand = PreparePartialCommandFromRemoteEntry (remoteEntry, localManifest);
                if (newCommand != null)
                {
                    partialCommands.Enqueue (newCommand);
                }

                // Remove entries from the local manifest, so we can later
                // tell which entries only exist locally
                if (localManifest.ContainsKey (remoteEntry.UrlHash))
                {
                    localManifest.Remove (remoteEntry.UrlHash);
                }
            }

            // Any entries left in the local manifest don't exist remotely,
            // so they need to be removed
            foreach (KeyValuePair <string, LocalManifestEntry> entryPair in localManifest)
            {
                CrawlCommand newCommand = new CrawlCommand ();
                newCommand.Action = CrawlAction.Remove;
                newCommand.Post = BuildFakePost (entryPair.Value);
                commands.Enqueue (newCommand);
            }
        }