mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-13 19:04:54 +01:00
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:
parent
2b3903a599
commit
3211cd0481
1 changed files with 5 additions and 3 deletions
|
@ -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()
|
||||||
|
|
Loading…
Reference in a new issue