From 3211cd04813736fca5f51e643429431d4449eb9e Mon Sep 17 00:00:00 2001 From: blinry Date: Mon, 12 Apr 2021 15:43:02 +0200 Subject: [PATCH] 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. --- scenes/helpers.gd | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scenes/helpers.gd b/scenes/helpers.gd index 5e5cebc..a354f45 100644 --- a/scenes/helpers.gd +++ b/scenes/helpers.gd @@ -91,11 +91,13 @@ func careful_delete(path_inside): var os = OS.get_name() 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": - 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": - 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: expected_prefix = expected_prefix.to_lower() path_inside = path_inside.to_lower()