Ejemplo n.º 1
0
            public virtual void UnpackRetryUpdater(IAbsoluteFilePath sourceFile, IAbsoluteDirectoryPath outputFolder,
                                                   bool overwrite = false, bool fullPath = true)
            {
                if (sourceFile == null)
                {
                    throw new ArgumentNullException(nameof(sourceFile));
                }
                if (outputFolder == null)
                {
                    throw new ArgumentNullException(nameof(outputFolder));
                }

                FileUtil.Ops.AddIORetryDialog(() => {
                    try {
                        Unpack(sourceFile, outputFolder, overwrite, fullPath);
                    } catch (UnauthorizedAccessException) {
                        if (!UacHelper.CheckUac())
                        {
                            throw;
                        }
                        UnpackUpdater(sourceFile, outputFolder, overwrite, fullPath);
                    } catch (IOException) {
                        if (!UacHelper.CheckUac())
                        {
                            throw;
                        }
                        UnpackUpdater(sourceFile, outputFolder, overwrite, fullPath);
                    }
                });
            }
Ejemplo n.º 2
0
 public void UnpackSingleGzipWithFallbackAndRetry(IAbsoluteFilePath sourceFile, IAbsoluteFilePath destFile)
 {
     FileUtil.Ops.AddIORetryDialog(() => {
         try {
             UnpackSingleGzip(sourceFile, destFile);
         } catch (UnauthorizedAccessException) {
             if (!UacHelper.CheckUac())
             {
                 throw;
             }
             UnpackSingleZipWithUpdaters(sourceFile, destFile);
         }
     });
 }
Ejemplo n.º 3
0
 public void DeleteWithUpdaterFallbackAndRetry(string source)
 {
     AddIORetryDialog(() => {
         try {
             DeleteIfExists(source);
         } catch (UnauthorizedAccessException ex) {
             this.Logger()
             .FormattedWarnException(ex,
                                     "Exception during delete, trying through updater if not elevated");
             if (!UacHelper.CheckUac())
             {
                 throw;
             }
             DeleteWithUpdater(source);
         }
     }, source);
 }
Ejemplo n.º 4
0
                public void MoveDirectoryWithUpdaterFallbackAndRetry(IAbsoluteDirectoryPath source,
                                                                     IAbsoluteDirectoryPath destination)
                {
                    AddIORetryDialog(() => {
                        if (IsSameRoot(source, destination))
                        {
                            try {
                                var tmp = destination + GenericTools.TmpExtension;
                                Directory.Move(source.ToString(), tmp);
                                Directory.Move(tmp, destination.ToString());
                            } catch (UnauthorizedAccessException ex) {
                                this.Logger()
                                .FormattedWarnException(ex,
                                                        "Exception during move directory, trying through updater if not elevated");
                                if (!UacHelper.CheckUac())
                                {
                                    throw;
                                }
                                MoveDirectoryWithUpdater(source, destination);
                            }
                        }
                        else
                        {
                            var doneCopy = false;
                            try {
                                CopyDirectoryWithRetry(source, destination, true);
                                doneCopy = true;
                            } catch (UnauthorizedAccessException ex) {
                                this.Logger()
                                .FormattedWarnException(ex,
                                                        "Exception during move directory, trying through updater if not elevated");
                                if (!UacHelper.CheckUac())
                                {
                                    throw;
                                }
                                MoveDirectoryWithUpdater(source, destination);
                            }

                            if (doneCopy)
                            {
                                DeleteWithUpdaterFallbackAndRetry(source.ToString());
                            }
                        }
                    }, source.ToString(), destination.ToString());
                }
Ejemplo n.º 5
0
 public void MoveWithUpdaterFallbackAndRetry(IAbsoluteFilePath source, IAbsoluteFilePath destination,
                                             bool overwrite = true, bool checkMd5 = false)
 {
     AddIORetryDialog(() => {
         try {
             Move(source, destination, overwrite, checkMd5);
         } catch (UnauthorizedAccessException ex) {
             this.Logger()
             .FormattedWarnException(ex,
                                     "Exception during move file, trying through updater if not elevated");
             if (!UacHelper.CheckUac())
             {
                 throw;
             }
             MoveWithUpdater(source, destination, overwrite);
         }
     }, source.ToString(), destination.ToString());
 }
Ejemplo n.º 6
0
 public void CopyDirectoryWithUpdaterFallbackAndRetry(IAbsoluteDirectoryPath sourceFolder,
                                                      IAbsoluteDirectoryPath outputFolder, bool overwrite = false)
 {
     AddIORetryDialog(() => {
         try {
             CopyDirectory(sourceFolder, outputFolder, overwrite);
         } catch (UnauthorizedAccessException ex) {
             this.Logger()
             .FormattedWarnException(ex,
                                     "Exception during copy directory, trying through updater if not elevated");
             if (!UacHelper.CheckUac())
             {
                 throw;
             }
             CopyDirectoryWithUpdater(sourceFolder, outputFolder, overwrite);
         } catch (IOException) {
             if (!UacHelper.CheckUac())
             {
                 throw;
             }
             CopyDirectoryWithUpdater(sourceFolder, outputFolder, overwrite);
         }
     }, sourceFolder.ToString(), outputFolder.ToString());
 }