public void Update() { if (_context.CurrentUpdaterDefinition == null) { _context.Logger.Warning("No updater definition found. The Launcher cannot be validated or updated."); return; } _context.Logger.Info("Launcher update started. The update contains {UpdateOperations} operations.", _context.CurrentUpdaterDefinition.Entries.Length); FilesManager.DeleteTemporaryDeletingFiles(_context.Settings.RootPath); foreach (var updaterDefinitionEntry in _context.CurrentUpdaterDefinition.Entries) { switch (updaterDefinitionEntry.Operation) { case PatchOperation.Added: _context.LogProgress(string.Format(_context.LocalizedMessages.UpdateProcessingNewFile, updaterDefinitionEntry.RelativePath)); HandleAddedFile(updaterDefinitionEntry); _context.ReportProgress(string.Format(_context.LocalizedMessages.UpdateProcessedNewFile, updaterDefinitionEntry.RelativePath)); continue; case PatchOperation.Deleted: _context.LogProgress(string.Format(_context.LocalizedMessages.UpdateProcessingDeletedFile, updaterDefinitionEntry.RelativePath)); HandleDeletedFile(updaterDefinitionEntry); _context.ReportProgress(string.Format(_context.LocalizedMessages.UpdateProcessedDeletedFile, updaterDefinitionEntry.RelativePath)); continue; case PatchOperation.ChangedAttributes: _context.LogProgress(string.Format(_context.LocalizedMessages.UpdateProcessingChangedAttributesFile, updaterDefinitionEntry.RelativePath)); HandleChangedAttributesFile(updaterDefinitionEntry); _context.ReportProgress(string.Format(_context.LocalizedMessages.UpdateProcessedChangedAttributesFile, updaterDefinitionEntry.RelativePath)); continue; case PatchOperation.Updated: _context.LogProgress(string.Format(_context.LocalizedMessages.UpdateProcessingUpdatedFile, updaterDefinitionEntry.RelativePath)); HandleUpdatedFile(updaterDefinitionEntry); _context.ReportProgress(string.Format(_context.LocalizedMessages.UpdateProcessedUpdatedFile, updaterDefinitionEntry.RelativePath)); continue; case PatchOperation.Unchanged: HandleUnchangedFile(updaterDefinitionEntry); _context.ReportProgress(string.Format(_context.LocalizedMessages.UpdateUnchangedFile, updaterDefinitionEntry.RelativePath)); continue; } } _context.Logger.Info("Launcher update completed."); }
private void PerformUpdate(PatchDefinition definition) { _context.LogProgress(string.Format(_context.LocalizedMessages.UpdateDownloadingArchive, definition.From, definition.To)); DownloadPatch(definition); _context.ReportProgress(string.Format(_context.LocalizedMessages.UpdateDownloadedArchive, definition.From, definition.To)); _context.LogProgress(string.Format(_context.LocalizedMessages.UpdateDecompressingArchive, definition.From, definition.To)); DecompressPatch(definition); _context.ReportProgress(string.Format(_context.LocalizedMessages.UpdateDecompressedArchive, definition.From, definition.To)); foreach (var definitionEntry in definition.Entries) { ProcessFile(definition, definitionEntry); } DirectoriesManager.Delete(_context.Settings.GetTempPath()); }