Repository: lutris/lutris

Issue:
Clicking cancel when moving the install directory still moves it
### Bug description

Clicking cancel when moving the install directory still moves it.

This is really annoying when you accidentally click somewhere, or accidentally choose your download folder etc.
Once moved my entire desktop into my downloads folder because of this.

### How to Reproduce

Steps to reproduce the behavior:
1. Go to any game
2. Click on configure
3. Under Game Info -> Directory click move
4. click anywhere that isnt the original location
5. Click cancel
6. See that the folder still moved to that location

### Expected behavior

When clicking cancel it should cancel the action and not move anything

### Log output

```shell
$ lutris -d
2021-12-18 22:46:05,509: Starting Lutris 0.5.9.1
2021-12-18 22:46:06,388: Startup complete
INFO     2021-12-18 22:46:06,393 [startup.check_driver:53]:Using NVIDIA drivers 495.44 for x86_64
INFO     2021-12-18 22:46:06,394 [startup.check_driver:57]:GPU: Unknown
INFO     2021-12-18 22:46:06,395 [startup.check_driver:73]:GPU: 10DE:1F02 1458:37C2 (nvidia drivers)
DEBUG    2021-12-18 22:46:07,082 [lutriswindow.update_store:451]:Showing 11 games
DEBUG    2021-12-18 22:46:10,759 [xrandr._get_vidmodes:14]:Retrieving video modes from XrandR
DEBUG    2021-12-18 22:46:10,800 [xrandr._get_vidmodes:14]:Retrieving video modes from XrandR
DEBUG    2021-12-18 22:46:10,815 [xrandr._get_vidmodes:14]:Retrieving video modes from XrandR
DEBUG    2021-12-18 22:46:10,829 [xrandr._get_vidmodes:14]:Retrieving video modes from XrandR
INFO     2021-12-18 22:46:20,499 [game.move:683]:Moving Steep (wine) to /home/julian/Games/1Storage/GOG Games
DEBUG    2021-12-18 22:46:20,500 [game.save:257]:Saving Steep (wine) with config ID steep-uplay-1625594663
```


### System Information

```shell
[System]
OS:              Manjaro Linux 21.2rc2 Qonos
Arch:            x86_64
Kernel:          5.4.163-1-MANJARO
Desktop:         XFCE
Display Server:  x11

[CPU]
Vendor:          GenuineIntel
Model:           Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
Physical cores:  6
Logical cores:   6

[Memory]
RAM:             31.4 GB
Swap:            32.0 GB

[Graphics]
Vendor:          NVIDIA Corporation
OpenGL Renderer: NVIDIA GeForce RTX 2070/PCIe/SSE2
OpenGL Version:  4.6.0 NVIDIA 495.44
OpenGL Core:     4.6.0 NVIDIA 495.44
OpenGL ES:       OpenGL ES 3.2 NVIDIA 495.44
Vulkan:          Supported
```


### Media (optional)

_No response_

### Checklist:

- [X] I'm not asking for support with a game or the wine runner.
- [X] I have followed the above mentioned guides and have all the graphics and wine dependencies installed.
- [X] I have checked for existing issues that describe my problem prior to opening this one.
- [X] I understand that improperly formatted bug reports may be closed without explanation.


Discussion:
Oh my, this isn't nice. All calls of DirectoryDialog fail to check for cancellation- they just use the folder blindly. If you cancel, the folder can still be used- just as if you had not cancelled.

The thing is, the DirectoryDialog has a weird interface and it's very easy to not do that check or not understand how to do it.

I've got a PR, but it's big because it tries to fix the underlying interface, so the caller does not get the folder if the user cancelled.

If that's not acceptable, we will need to do a narrower fix. The critical spot is GameDialogCommon.on_move_clicked in lutris/gui/config/common.py

Resolving patch:
diff --git a/lutris/gui/dialogs/__init__.py b/lutris/gui/dialogs/__init__.py
--- a/lutris/gui/dialogs/__init__.py
+++ b/lutris/gui/dialogs/__init__.py
@@ -123,6 +123,7 @@ class DirectoryDialog(Gtk.FileChooserDialog):
     """Ask the user to select a directory."""
 
     def __init__(self, message, default_path=None, parent=None):
+        self.folder = None
         super().__init__(
             title=message,
             action=Gtk.FileChooserAction.SELECT_FOLDER,
@@ -132,7 +133,8 @@ def __init__(self, message, default_path=None, parent=None):
         if default_path:
             self.set_current_folder(default_path)
         self.result = self.run()
-        self.folder = self.get_current_folder()
+        if self.result == Gtk.ResponseType.OK:
+            self.folder = self.get_current_folder()
         self.destroy()
 
 


Test patch: