Beispiel #1
0
        public void DisposeOfBackup(string installDir, BackupDisposalProcedure procedure)
        {
            string backupDir = string.Format("_gpbackup_{0}", installDir);

            SteamRoot.Instance.SteamRestartRequired = true;
            switch (procedure)
            {
            case BackupDisposalProcedure.BackupThenDelete:
                try
                {
                    DeleteBackupDir(installDir);
                    Logging.Logger.InfoFormat("Deleted backup directory {0} after a successful transfer.", backupDir, installDir);
                }
                catch (Exception ex)
                {
                    Logging.Logger.Error(string.Format("Failed to delete the backup of old files after a successful transfer.\nPlease manually delete the {0} directory.", backupDir), ex);
                    System.Windows.MessageBox.Show(string.Format("Failed to delete the backup of old files after a successful transfer.\nPlease manually delete the {0} directory.\n\nPress ok to the backup directory now.", backupDir), "Delete Backup failed", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Exclamation, System.Windows.MessageBoxResult.OK);
                    OpenGameDir(installDir, false, true);
                }
                break;

            case BackupDisposalProcedure.BackupThenMerge:
                throw new NotImplementedException("Not yet implemented");
                break;

            case BackupDisposalProcedure.BackupThenOpen:
                string backupPath = Path.Combine(SteamDirectory, "common", backupDir);
                if (Directory.Exists(backupPath))
                {
                    OpenGameDir(installDir, true, true);
                }
                break;
            }
        }
Beispiel #2
0
        public void QueueTransfer()
        {
            _actualDiskSize = _source.GetMeasuredGameSize(Application.AppId);
            if (_target.GetFreeSpace() < _actualDiskSize)
            {
                Task.Run(() =>
                {
                    System.Threading.Thread.Sleep(1000);    //TODO this is a little lazy, replace this if I get a proper scheduler.
                    string message = string.Format("The destination only has {0} free, {1} is {2}.\nThe transfer cannot be completed.",
                                                   Utils.FileUtils.GetReadableFileSize(_target.GetFreeSpace()),
                                                   Utils.FileUtils.GetReadableFileSize(_actualDiskSize),
                                                   Application.GameName);
                    Utils.Logging.Logger.Error(message);
                    System.Windows.MessageBox.Show(message, "Insufficient Disk Space", System.Windows.MessageBoxButton.OK,
                                                   System.Windows.MessageBoxImage.Exclamation, System.Windows.MessageBoxResult.OK);
                });
            }
            //else if (_target.HasApp(Application.AppId))
            //{

            //}
            else if (_target.HasGameDir(Application.InstallDir) && _actualDiskSize > 0)
            {
                Task.Run(() =>
                {
                    //Don't show the dialog immediately after the mouse button gets released, that's just asking for trouble.
                    System.Threading.Thread.Sleep(1000);    //TODO this is a little lazy, replace this if I get a proper scheduler.
                    var result = System.Windows.MessageBox.Show(string.Format("A directory already exists at the transfer destination {0}.\nHow would you like to handle it?\n\nYes = Backup the directory, then delete it upon successful copy.\nNo = Backup the directory, then open it upon a successful copy, and I will decide what to do.\nCancel = Just abort the transfer.\n\n", Application.InstallDir),
                                                                "Directory Already Exists", System.Windows.MessageBoxButton.YesNoCancel, System.Windows.MessageBoxImage.Exclamation, System.Windows.MessageBoxResult.Cancel);
                    switch (result)
                    {
                    case System.Windows.MessageBoxResult.Yes:
                        _desiredBackupBehavior = BackupDisposalProcedure.BackupThenDelete;
                        TransferManager.Instance.AddTransfer(this);
                        break;

                    case System.Windows.MessageBoxResult.No:
                        _desiredBackupBehavior = BackupDisposalProcedure.BackupThenOpen;
                        TransferManager.Instance.AddTransfer(this);
                        break;

                    default:
                    case System.Windows.MessageBoxResult.Cancel:
                        (_target as Steam.SteamLibrary)?.OpenGameDir(Application.InstallDir, true, true);
                        break;
                    }
                });
            }
            else
            {
                TransferManager.Instance.AddTransfer(this);
            }
        }