Fix loading packages.json when file doesn't exist yet

Contributes to issue CURA-5364.
This commit is contained in:
Ghostkeeper 2018-05-15 11:23:26 +02:00
parent 0a9f389396
commit 0aa1aaf11b
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A

View file

@ -29,6 +29,8 @@ class CuraPackageManager(QObject):
self._plugin_registry = self._application.getPluginRegistry() self._plugin_registry = self._application.getPluginRegistry()
#JSON files that keep track of all installed packages. #JSON files that keep track of all installed packages.
self._user_package_management_file_path = None
self._bundled_package_management_file_path = None
for search_path in Resources.getSearchPaths(): for search_path in Resources.getSearchPaths():
candidate_bundled_path = os.path.join(search_path, "bundled_packages.json") candidate_bundled_path = os.path.join(search_path, "bundled_packages.json")
if os.path.exists(candidate_bundled_path): if os.path.exists(candidate_bundled_path):
@ -36,6 +38,8 @@ class CuraPackageManager(QObject):
candidate_user_path = os.path.join(search_path, "packages.json") candidate_user_path = os.path.join(search_path, "packages.json")
if os.path.exists(candidate_user_path): if os.path.exists(candidate_user_path):
self._user_package_management_file_path = candidate_user_path self._user_package_management_file_path = candidate_user_path
if self._user_package_management_file_path is None: #Doesn't exist yet.
self._user_package_management_file_path = os.path.join(Resources.getDataStoragePath(), "packages.json")
self._bundled_package_dict = {} # A dict of all bundled packages self._bundled_package_dict = {} # A dict of all bundled packages
self._installed_package_dict = {} # A dict of all installed packages self._installed_package_dict = {} # A dict of all installed packages