protected void UpdateCoreInfos() { if (!TryCreateDirectory(_infoDirectory)) { return; } if (!TryCreateAbsoluteUrl(_baseUrl, _infoUrl, out Uri uri)) { ServiceRegistration.Get <ILogger>().Error("CoreHandler: Unable to create absolute core info url from settings, base url: '{0}', info url: '{1}'", _baseUrl, _infoUrl); return; } try { byte[] data = _downloader.DownloadDataAsync(uri.AbsoluteUri).Result; if (data == null || data.Length == 0) { ServiceRegistration.Get <ILogger>().Error("CoreInfoHandler: Failed to download core infos from '{0}', response was null or empty", uri.AbsoluteUri); return; } using (Stream stream = new MemoryStream(data)) using (IExtractor extractor = ExtractorFactory.Create(uri.AbsoluteUri, stream)) extractor.ExtractAll(_infoDirectory); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Error("CoreInfoHandler: Exception updating core infos", ex); } }
protected bool ExtractCore(string path) { bool extracted; using (IExtractor extractor = ExtractorFactory.Create(path)) { if (!extractor.IsArchive()) { return(true); } extracted = extractor.ExtractAll(Path.GetDirectoryName(path)); } if (extracted) { TryDeleteFile(path); } return(extracted); }