diff --git a/bottles/backend/wine/drives.py b/bottles/backend/wine/drives.py index a104c79dbb..5fc80e86c7 100644 --- a/bottles/backend/wine/drives.py +++ b/bottles/backend/wine/drives.py @@ -32,16 +32,19 @@ def get_drive(self, letter: str): return self.get_all().get(letter) return None - def new_drive(self, letter: str, path: str): - """Add a new drive to the bottle""" + def set_drive_path(self, letter: str, path: str): + """Change a drives path in the bottle""" letter = f"{letter}:".lower() + drive_sym_path = os.path.join(self.dosdevices_path, letter) if not os.path.exists(self.dosdevices_path): os.makedirs(self.dosdevices_path) - try: - os.symlink(path, os.path.join(self.dosdevices_path, letter)) + if not os.path.exists(drive_sym_path): + os.symlink(path, drive_sym_path) logging.info(f"New drive {letter} added to the bottle") - except FileExistsError: - logging.warning(f"Drive {letter} already exists in the bottle, no drive added") + else: + os.remove(drive_sym_path) + os.symlink(path, drive_sym_path) + logging.info(f"Drive {letter} path changed to {path}") def remove_drive(self, letter: str): """Remove a drive from the bottle""" diff --git a/bottles/frontend/windows/drives.py b/bottles/frontend/windows/drives.py index ba74762eb8..7482543545 100644 --- a/bottles/frontend/windows/drives.py +++ b/bottles/frontend/windows/drives.py @@ -64,7 +64,7 @@ def set_path(_dialog, response): return path = dialog.get_file().get_path() - Drives(self.config).new_drive(self.drive[0], path) + Drives(self.config).set_drive_path(self.drive[0], path) self.set_subtitle(path) dialog = Gtk.FileChooserNative.new(