Use HOME variables in careful_delete

This helps in cases where the home directory is in unexpected places,
like on external hard drives, and should still be very safe.

Closes #60, closes #81.
This commit is contained in:
blinry 2021-04-12 15:43:02 +02:00
parent 2b3903a599
commit 3211cd0481

View file

@ -91,11 +91,13 @@ func careful_delete(path_inside):
var os = OS.get_name() var os = OS.get_name()
if os == "X11": if os == "X11":
expected_prefix = "/home/%s/.local/share/Oh My Git/tmp/" % OS.get_environment("USER") expected_prefix = "%s/.local/share/Oh My Git/tmp/" % OS.get_environment("HOME")
elif os == "OSX": elif os == "OSX":
expected_prefix = "/Users/%s/Library/Application Support/Oh My Git/tmp/" % OS.get_environment("USER") expected_prefix = "%s/Library/Application Support/Oh My Git/tmp/" % OS.get_environment("HOME")
elif os == "Windows": elif os == "Windows":
expected_prefix = "C:/Users/%s/AppData/Roaming/Oh My Git/tmp/" % OS.get_environment("USERNAME") expected_prefix = "%s/AppData/Roaming/Oh My Git/tmp/" % OS.get_environment("USERPROFILE")
# In the game, we use forward slashes:
expected_prefix = expected_prefix.replace("\\", "/")
# Windows treats paths case-insensitively: # Windows treats paths case-insensitively:
expected_prefix = expected_prefix.to_lower() expected_prefix = expected_prefix.to_lower()
path_inside = path_inside.to_lower() path_inside = path_inside.to_lower()