From 18f984ab3e79bb157e96048674648ae61c0892f0 Mon Sep 17 00:00:00 2001 From: Grigorii Horos Date: Sat, 4 Nov 2023 19:57:59 +0200 Subject: [PATCH] Add Windows AppData support --- mackup/constants.py | 1 + mackup/utils.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mackup/constants.py b/mackup/constants.py index f8c2fe6f0..6cbec7669 100644 --- a/mackup/constants.py +++ b/mackup/constants.py @@ -5,6 +5,7 @@ # Support platforms PLATFORM_DARWIN = "Darwin" PLATFORM_LINUX = "Linux" +PLATFORM_WINDOWS = "Windows" # Directory containing the application configs APPS_DIR = "applications" diff --git a/mackup/utils.py b/mackup/utils.py index 7ebc73e30..7e98d781a 100644 --- a/mackup/utils.py +++ b/mackup/utils.py @@ -390,8 +390,17 @@ def can_file_be_synced_on_current_platform(path): # not any file/folder named LibrarySomething library_path = os.path.join(os.environ["HOME"], "Library/") - if platform.system() == constants.PLATFORM_LINUX: + if platform.system() == constants.PLATFORM_LINUX or platform.system() == constants.PLATFORM_WINDOWS: if fullpath.startswith(library_path): can_be_synced = False + # Compute the ~/AppData path on Windows + # End it with a slash because we are looking for this specific folder and + # not any file/folder named AppDataSomething + appdata_path = os.path.join(os.environ["HOME"], "AppData/") + + if platform.system() == constants.PLATFORM_LINUX or platform.system() == constants.PLATFORM_DARWIN: + if fullpath.startswith(appdata_path): + can_be_synced = False + return can_be_synced