Change config dir, offer to migrate

Moment has different default directories and is controlled by
different environment variables. On first startup, Moment
detects Mirage directories and offers to copy them.
It doesn't make sense to migrate logins without migrating encryption
keys, so this is now included in migration. Themes are migrated as well.
Only offer migration is only if both config and data directory are able to be
migrated.
This commit is contained in:
Maze
2022-01-14 19:27:59 +00:00
parent 63a56d92fd
commit 2839f83dde
9 changed files with 268 additions and 29 deletions

View File

@@ -1,7 +1,7 @@
# Copyright Mirage authors & contributors <https://github.com/mirukana/mirage>
# SPDX-License-Identifier: LGPL-3.0-or-later
"""This package provides Mirage's backend side that can interact with the UI.
"""This package provides Moment's backend side that can interact with the UI.
To learn more about how this package works, you might want to check the
documentation in the following modules first:
@@ -12,7 +12,7 @@ documentation in the following modules first:
- `nio_callbacks`
"""
__app_name__ = "mirage"
__display_name__ = "Mirage"
__reverse_dns__ = "io.github.mirukana.mirage"
__app_name__ = "moment"
__display_name__ = "Moment"
__reverse_dns__ = "xyz.mx-moment"
__version__ = "0.7.2"

View File

@@ -104,7 +104,7 @@ class Backend:
media_cache: A matrix media cache for downloaded files.
presences: A `{user_id: Presence}` dict for storing presence info about
matrix users registered on Mirage.
matrix users registered on Moment.
mxc_events: A dict storing media `Event` model items for any account
that have the same mxc URI
@@ -137,7 +137,7 @@ class Backend:
DefaultDict(asyncio.Lock) # {room_id: lock}
cache_dir = Path(
os.environ.get("MIRAGE_CACHE_DIR") or self.appdirs.user_cache_dir,
os.environ.get("MOMENT_CACHE_DIR") or self.appdirs.user_cache_dir,
)
self.media_cache: MediaCache = MediaCache(self, cache_dir)

View File

@@ -95,7 +95,7 @@ class Media:
<base download folder>/<homeserver domain>/
<file title>_<mxc id>.<file extension>`
```
e.g. `~/.cache/mirage/downloads/matrix.org/foo_Hm24ar11i768b0el.png`.
e.g. `~/.cache/moment/downloads/matrix.org/foo_Hm24ar11i768b0el.png`.
"""
parsed = urlparse(self.mxc)
@@ -304,7 +304,7 @@ class Thumbnail(Media):
<file title>_<mxc id>.<file extension>`
```
e.g.
`~/.cache/mirage/thumbnails/matrix.org/32x32/foo_Hm24ar11i768b0el.png`.
`~/.cache/moment/thumbnails/matrix.org/32x32/foo_Hm24ar11i768b0el.png`.
"""
size = self.normalize_size(self.server_size or self.wanted_size)

View File

@@ -197,7 +197,7 @@ class ConfigFile(UserFile):
@property
def path(self) -> Path:
return Path(
os.environ.get("MIRAGE_CONFIG_DIR") or
os.environ.get("MOMENT_CONFIG_DIR") or
self.backend.appdirs.user_config_dir,
) / self.filename
@@ -209,7 +209,7 @@ class UserDataFile(UserFile):
@property
def path(self) -> Path:
return Path(
os.environ.get("MIRAGE_DATA_DIR") or
os.environ.get("MOMENT_DATA_DIR") or
self.backend.appdirs.user_data_dir,
) / self.filename
@@ -460,7 +460,7 @@ class NewTheme(UserDataFile, PCNFile):
@property
def path(self) -> Path:
data_dir = Path(
os.environ.get("MIRAGE_DATA_DIR") or
os.environ.get("MOMENT_DATA_DIR") or
self.backend.appdirs.user_data_dir,
)
return data_dir / "themes" / self.filename
@@ -515,7 +515,7 @@ class Theme(UserDataFile):
@property
def path(self) -> Path:
data_dir = Path(
os.environ.get("MIRAGE_DATA_DIR") or
os.environ.get("MOMENT_DATA_DIR") or
self.backend.appdirs.user_data_dir,
)
return data_dir / "themes" / self.filename