Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ability to change drive location #2944

Merged
merged 3 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions bottles/backend/wine/drives.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
2 changes: 1 addition & 1 deletion bottles/frontend/windows/drives.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down