Exemplo n.º 1
0
 public override async Task DoWork(UpdateTaskExecutor executor)
 {
     if (_path.EndsWith("/"))
     {
         // directory
         var target = Path.Combine(executor.BasePath, _path.Substring(0, _path.Length - 1));
         if (Directory.Exists(target))
         {
             executor.NotifyProgress("removing directory: " + _path + " ...", false);
             await Task.Run(() => Directory.Delete(target, true));
         }
         else
         {
             executor.NotifyProgress("directory " + _path + " is not existed. nothing to do.");
         }
     }
     else
     {
         // file
         var target = Path.Combine(executor.BasePath, _path);
         if (File.Exists(target))
         {
             executor.NotifyProgress("removing file: " + _path + " ...", false);
             await Task.Run(() => File.Delete(target));
         }
         else
         {
             executor.NotifyProgress("file " + _path + " is not existed. nothing to do.");
         }
     }
     executor.NotifyProgress("ok.");
 }
Exemplo n.º 2
0
        public override async Task DoWork(UpdateTaskExecutor executor)
        {
            executor.NotifyProgress("removing file: " + _path + " ...", false);
            await Task.Run(() => File.Delete(Path.Combine(executor.BasePath, _path)));

            executor.NotifyProgress("ok.");
        }
Exemplo n.º 3
0
        public override async Task DoWork(UpdateTaskExecutor executor)
        {
            executor.NotifyProgress("executing binary: " + _path);
            var process = Process.Start(Path.Combine(executor.BasePath, _path));

            if (_awaitProcess && process != null)
            {
                executor.NotifyProgress("waiting exit...", false);
                await Task.Run(() => process.WaitForExit());

                executor.NotifyProgress("ok.");
            }
        }
Exemplo n.º 4
0
 public async override Task DoWork(UpdateTaskExecutor executor)
 {
     executor.NotifyProgress("downloading patch package...");
     var file = await executor.DownloadBinary(Url);
     using (var ms = new MemoryStream(file))
     using (var ss = new MemoryStream())
     {
         if (!Cryptography.Verify(ms, ss, executor.PublicKey))
         {
             executor.NotifyProgress("Invalid signature.");
             throw new Exception("Package signature is not matched.");
         }
         var archive = new ZipArchive(ss);
         foreach (var entry in archive.Entries)
         {
             await this.Extract(entry, executor.BasePath);
         }
     }
 }
Exemplo n.º 5
0
        public async override Task DoWork(UpdateTaskExecutor executor)
        {
            executor.NotifyProgress("downloading patch package...");
            byte[] file = null;
            for (var i = 0; i < 3; i++)
            {
                file = await executor.DownloadBinary(this.Url);

                if (file != null)
                {
                    break;
                }
                executor.NotifyProgress("<!> patch package download failed. awaiting server a few seconds...", false);
                await Task.Run(() => Thread.Sleep(10000));

                executor.NotifyProgress("retrying download patch package...");
            }
            if (file == null)
            {
                executor.NotifyProgress("***** FATAL: patch package download failed! *****");
                throw new UpdateException("patch package download failed.");
            }
            using (var ms = new MemoryStream(file))
                using (var ss = new MemoryStream())
                {
                    executor.NotifyProgress("verifying patch pack...", false);
                    if (!Cryptography.Verify(ms, ss, executor.PublicKey))
                    {
                        executor.NotifyProgress("Invalid signature.");
                        throw new UpdateException("patch package signature is not valid.");
                    }
                    executor.NotifyProgress("verified.");
                    executor.NotifyProgress("applying patches.");
                    var archive = new ZipArchive(ss);
                    foreach (var entry in archive.Entries)
                    {
                        executor.NotifyProgress("patching " + entry.Name + "...");
                        await this.Extract(entry, executor.BasePath);
                    }
                    executor.NotifyProgress("patch completed.");
                }
        }
Exemplo n.º 6
0
 public async override Task DoWork(UpdateTaskExecutor executor)
 {
     executor.NotifyProgress("downloading patch package...");
     byte[] file = null;
     for (var i = 0; i < 3; i++)
     {
         file = await executor.DownloadBinary(this.Url);
         if (file != null) break;
         executor.NotifyProgress("<!> patch package download failed. awaiting server a few seconds...", false);
         await Task.Run(() => Thread.Sleep(10000));
         executor.NotifyProgress("retrying download patch package...");
     }
     if (file == null)
     {
         executor.NotifyProgress("***** FATAL: patch package download failed! *****");
         throw new UpdateException("patch package download failed.");
     }
     using (var ms = new MemoryStream(file))
     using (var ss = new MemoryStream())
     {
         executor.NotifyProgress("verifying patch pack...", false);
         if (!Cryptography.Verify(ms, ss, executor.PublicKey))
         {
             executor.NotifyProgress("Invalid signature.");
             throw new UpdateException("patch package signature is not valid.");
         }
         executor.NotifyProgress("verified.");
         executor.NotifyProgress("applying patches.");
         var archive = new ZipArchive(ss);
         foreach (var entry in archive.Entries)
         {
             executor.NotifyProgress("patching " + entry.Name + "...");
             await this.Extract(entry, executor.BasePath);
         }
         executor.NotifyProgress("patch completed.");
     }
 }
Exemplo n.º 7
0
 public override async Task DoWork(UpdateTaskExecutor executor)
 {
     if (_path.EndsWith("/"))
     {
         // directory
         var target = Path.Combine(executor.BasePath, _path.Substring(0, _path.Length - 1));
         if (Directory.Exists(target))
         {
             executor.NotifyProgress("removing directory: " + _path + " ...", false);
             await Task.Run(() => Directory.Delete(target, true));
         }
         else
         {
             executor.NotifyProgress("directory " + _path + " is not existed. nothing to do.");
         }
     }
     else
     {
         // file
         var target = Path.Combine(executor.BasePath, _path);
         if (File.Exists(target))
         {
             executor.NotifyProgress("removing file: " + _path + " ...", false);
             await Task.Run(() => File.Delete(target));
         }
         else
         {
             executor.NotifyProgress("file " + _path + " is not existed. nothing to do.");
         }
     }
     executor.NotifyProgress("ok.");
 }
Exemplo n.º 8
0
 public override async Task DoWork(UpdateTaskExecutor executor)
 {
     executor.NotifyProgress("executing binary: " + _path);
     var process = Process.Start(Path.Combine(executor.BasePath, _path));
     if (_awaitProcess && process != null)
     {
         executor.NotifyProgress("waiting exit...", false);
         await Task.Run(() => process.WaitForExit());
         executor.NotifyProgress("ok.");
     }
 }
Exemplo n.º 9
0
 public override async Task DoWork(UpdateTaskExecutor executor)
 {
     executor.NotifyProgress("removing file: " + _path + " ...", false);
     await Task.Run(() => File.Delete(Path.Combine(executor.BasePath, _path)));
     executor.NotifyProgress("ok.");
 }
Exemplo n.º 10
0
 public override async Task DoWork(UpdateTaskExecutor executor)
 {
     if (_path.EndsWith("/"))
     {
         // directory
         executor.NotifyProgress("removing directory: " + _path + " ...", false);
         await Task.Run(() => Directory.Delete(
             Path.Combine(executor.BasePath, _path.Substring(0, _path.Length - 1)),
             true));
     }
     else
     {
         // file
         executor.NotifyProgress("removing file: " + _path + " ...", false);
         await Task.Run(() => File.Delete(Path.Combine(executor.BasePath, _path)));
     }
     executor.NotifyProgress("ok.");
 }