Esempio n. 1
0
 void CheckOrUpdateCatalog()
 {
     var progress = Log.Action(2, "Checking and/or updating catalog...");
     var books = new BookSource { Log = Log };
     var volumes = new VolumeSource { Log = Log };
     if (!string.IsNullOrEmpty(ActualDirectory)) {
         books.SetDirectory(ActualDirectory);
         volumes.SetDirectory(ActualDirectory);
     }
     var updater = new CatalogUpdater { Log = Log };
     Date localDate = Date.MinValue;
     if (Always || updater.ShouldUpdate(books, volumes, out localDate)) {
         progress.Continue("Downloading remote catalog...");
         var catalog = new Catalog { Log = Log };
         if (!string.IsNullOrEmpty(URL))
             catalog.SetUrl(URL);
         using (var stream = catalog.Open())
             updater.TryUpdate(stream, books, volumes,
                 remoteDate => localDate == Date.MinValue || localDate < remoteDate,
                 () => ShouldProcess("Catalog", "Update") && (Force ||
                 ShouldContinue("Do you really want to update the local catalog?",
                                "Catalog Update")));
     }
     progress.Finish();
 }