Make the file paths cross-platform compatible

This commit is contained in:
Kosh 2023-10-15 13:50:52 +05:30
parent bc570b4eec
commit 8a2c2d02d9
2 changed files with 9 additions and 3 deletions

View File

@ -54,7 +54,8 @@ class DataHandler:
WARNING:-
If this is the first time the app is opened, the user_name will be shown as wrong
"""
self.__file_path = appdirs.user_data_dir(appname="Unnamed_Password_Manager")
self.__file_path = appdirs.user_data_dir()
self.__file_path = path.join(self.__file_path, "Unnamed_Password_Manager")
self.__user_name = user_name
self.__file_path = path.join(self.__file_path, self.__user_name)
self.__password = password
@ -77,7 +78,8 @@ class DataHandler:
If user_name exists, ValueError is thrown
"""
file_path = path.join(
appdirs.user_data_dir(appname="Unnamed_Password_Manager"),
appdirs.user_data_dir(),
"Unnamed_Password_Manager",
user_name
)
if path.exists(file_path):

View File

@ -10,7 +10,11 @@ app: Flask = Flask(__name__)
def handle_first_launched():
folder_path: str = appdirs.user_data_dir(appname="Unnamed_Password_Manager")
"""
Makes sure everything is initialized correctly
"""
folder_path: str = appdirs.user_data_dir()
folder_path = path.join(folder_path, "Unnamed_Password_Manager")
if not path.exists(folder_path):
mkdir(folder_path)