Ejemplo n.º 1
0
        async Task <CoreUpdaterInfo> CheckForUpdatesAsync(string jsonUrl)
        {
            var appInfo = await DownloadJsonAsync(jsonUrl);

            // Deserialize
            CoreUpdaterInfo = CoreUpdaterInfo.ReadString(appInfo);

            return(CoreUpdaterInfo);
        }
Ejemplo n.º 2
0
        public void StartUpdater(CoreUpdaterInfo coreUpdaterInfo, ExecutionType executonType = ExecutionType.Default)
        {
            var assemblyName = Path.GetFileName(Assembly.GetEntryAssembly().Location);
            var srcDir       = Path.GetFullPath(coreUpdaterInfo.GetNewVersionDir());
            var dstDir       = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var processId    = Process.GetCurrentProcess().Id.ToString();

            StartUpdater(assemblyName, srcDir, dstDir, processId, executonType);
        }
Ejemplo n.º 3
0
 void CopyFiles(string srcDir, string dstDir, CoreUpdaterInfo srcAppinfo)
 {
     foreach (var file in srcAppinfo.Files)
     {
         File.Copy($@"{srcDir}\{file.Name}", $@"{dstDir}\{file.Name}", true);
         logger?.LogDebug($@"[Copy] {srcDir}\{file.Name}");
     }
     File.Copy($@"{srcDir}\{CoreUpdaterInfoFileName}", $@"{dstDir}\{CoreUpdaterInfoFileName}", true);
     logger?.LogDebug($@"[Copy] {srcDir}\{CoreUpdaterInfoFileName}");
 }
Ejemplo n.º 4
0
 void DeleteFiles(string dir, CoreUpdaterInfo appinfo)
 {
     // Delete file in current dir.
     foreach (var file in appinfo.Files)
     {
         File.Delete($@"{dir}\{file.Name}");
         logger?.LogDebug($@"[Delete] {dir}\{file.Name}");
     }
     File.Delete($@"{dir}\{CoreUpdaterInfoFileName}");
     logger?.LogDebug($@"[Delete] {dir}\{CoreUpdaterInfoFileName}");
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Download zip from GitHub, and extract it
        /// </summary>
        /// <param name="zipFileName"></param>
        /// <param name="outputDir"></param>
        /// <returns></returns>
        public override async Task <CoreUpdaterInfo> PrepareForUpdatesAsync(string outputDir, string zipFileName)
        {
            var tag = await GetLatestReleaseTagAsync();

            var jsonUrl = GetAssetUrl(tag, CoreUpdaterInfoFileName);
            var zipUrl  = GetAssetUrl(tag, zipFileName);

            var appInfo = await CheckForUpdatesAsync(jsonUrl);

            var outputPath = $@"{outputDir}\{zipFileName}";

            await DownloadZipAsync(zipUrl, outputPath);

            Zip.ExtractEntries(outputPath, appInfo.GetNewVersionDir());

            // Delete downloaded zip file.
            File.Delete(outputPath);

            return(CoreUpdaterInfo.ReadFile($@"{appInfo.GetNewVersionDir()}\{CoreUpdaterInfoFileName}"));
        }
Ejemplo n.º 6
0
 public override async Task <CoreUpdaterInfo> PrepareForUpdatesAsync(string outputDir, CoreUpdaterInfo coreUpdaterInfo)
 {
     return(await PrepareForUpdatesAsync(outputDir, coreUpdaterInfo.Name + ".zip"));
 }
Ejemplo n.º 7
0
 public abstract Task <CoreUpdaterInfo> PrepareForUpdatesAsync(string outputDir, CoreUpdaterInfo coreUpdaterInfo);