public bool Prepare(IUpdateSource source) { try { if (!Directory.Exists(UpdateManager.Instance.TempPath)) Directory.CreateDirectory(UpdateManager.Instance.TempPath); //download zip file to tmp folder if (!source.DownloadUpdate(RemotePath, PathToZippedUpdate)) throw new Exception("Impossible de télécharger la mise à jour"); //check file checksum if (!string.IsNullOrEmpty(Checksum)) { string checksum = FileChecksum.GetSHA256Checksum(PathToZippedUpdate); if (!checksum.Equals(Checksum)) throw new Exception("Le fichier de mise à jour téléchargé n'est pas valide"); } //extract file to temp folder and delete the zip file. ZipFileUil.Extract(PathToZippedUpdate, UpdateManager.Instance.TempPath); //delete the zipped file if (File.Exists(PathToZippedUpdate)) File.Delete(PathToZippedUpdate); } catch (Exception) { Clear(); throw; } return true; }
public async Task<IUpdatePackage> DownloadUpdate(IUpdateSource source) { try { var tempDir = Path.GetTempPath(); var location = new DirectoryInfo(Path.Combine(tempDir,"Revise",source.Name,Guid.NewGuid().ToString())); return await source.DownloadUpdate(location); } catch (Exception e) { Log.Warn("[DownloadUpdate] Error download update for " + source.Name,e); return null; } }