From 02d7193a921308c34a026bf6457726d552c53497 Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 8 Dec 2017 20:09:23 -0500 Subject: [PATCH] [V3 Downloader] Fix non relative data path (#1150) --- redbot/cogs/downloader/installable.py | 7 +++++-- redbot/cogs/downloader/repo_manager.py | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/redbot/cogs/downloader/installable.py b/redbot/cogs/downloader/installable.py index 3284c4e40..248d3ebb6 100644 --- a/redbot/cogs/downloader/installable.py +++ b/redbot/cogs/downloader/installable.py @@ -5,6 +5,7 @@ from enum import Enum from pathlib import Path from typing import Union, MutableMapping, Any +from redbot.core import data_manager from .log import log from .json_mixins import RepoJSONMixin @@ -191,11 +192,13 @@ class Installable(RepoJSONMixin): return info def to_json(self): + data_path = data_manager.cog_data_path() return { - "location": self._location.relative_to(Path.cwd()).parts + "location": self._location.relative_to(data_path).parts } @classmethod def from_json(cls, data: dict): - location = Path.cwd() / Path(*data["location"]) + data_path = data_manager.cog_data_path() + location = data_path / Path(*data["location"]) return cls(location=location) diff --git a/redbot/cogs/downloader/repo_manager.py b/redbot/cogs/downloader/repo_manager.py index 593d6ec3a..3507c14f8 100644 --- a/redbot/cogs/downloader/repo_manager.py +++ b/redbot/cogs/downloader/repo_manager.py @@ -468,19 +468,21 @@ class Repo(RepoJSONMixin): ) def to_json(self): + data_path = data_manager.cog_data_path() return { "url": self.url, "name": self.name, "branch": self.branch, - "folder_path": self.folder_path.relative_to(Path.cwd()).parts, + "folder_path": self.folder_path.relative_to(data_path).parts, "available_modules": [m.to_json() for m in self.available_modules] } @classmethod def from_json(cls, data): + data_path = data_manager.cog_data_path() # noinspection PyTypeChecker return Repo(data['name'], data['url'], data['branch'], - Path.cwd() / Path(*data['folder_path']), + data_path / Path(*data['folder_path']), tuple([Installable.from_json(m) for m in data['available_modules']]))