Skip to content

Commit

Permalink
#289: Add OS drive roots
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Dec 22, 2023
1 parent 807e4a9 commit da57555
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
which Ludusavi will download and use just like the primary one.
This allows the community to create additional save lists for specific purposes
that might not be covered by PCGamingWiki.
* You can now configure roots for OS installations on other drives.
New root types: `Windows drive`, `Linux drive`, `Mac drive`
* CLI: `wrap` command to do a restore before playing a game and a backup afterwards.
([Contributed by sluedecke](https://github.com/mtkennerly/ludusavi/pull/235))
* When a path or URL fails to open, additional information is now logged.
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@ along with the root's type:
* For a Wine prefix root, this should be the folder containing `drive_c`.
Currently, Ludusavi does not back up registry-based saves from the prefix,
but will back up any file-based saves.
<!--
* The Windows, Linux, and Mac drive roots can be used
to make Ludusavi scan external hard drives with a separate OS installation.
For example, let's say you had a Windows laptop that broke,
but you recovered the hard drive and turned it into an external drive.
You could add it as a Windows drive root to make Ludusavi scan it.
In this case, Ludusavi can only look for normal/default locations of system folders.
Ludusavi will not be able to use the Windows API or check `XDG` environment variables
to detect alternative folder locations (e.g., if you've moved the `Documents` folder).
-->

You may use [globs] in root paths to identify multiple roots at once.
If you have a folder name that contains a special glob character,
Expand Down Expand Up @@ -551,7 +562,7 @@ Here are the available settings in `config.yaml` (all are required unless otherw
* `path` (string): Where the root is located on your system.
* `store` (string): Game store associated with the root. Valid options:
`ea`, `epic`, `gog`, `gogGalaxy`, `heroic`, `lutris`, `microsoft`, `origin`, `prime`,
`steam`, `uplay`, `otherHome`, `otherWine`, `other`
`steam`, `uplay`, `otherHome`, `otherWine`, <!-- `otherWindows`, `otherLinux`, `otherMac`, --> `other`
* `redirects` (optional, list):
* Each entry in the list should be a map with these fields:
* `kind` (string): When and how to apply the redirect.
Expand Down
3 changes: 3 additions & 0 deletions lang/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ store-steam = Steam
store-uplay = Uplay
store-other-home = Home folder
store-other-wine = Wine prefix
store-other-windows = Windows drive
store-other-linux = Linux drive
store-other-mac = Mac drive
store-other = Other
backup-format-simple = Simple
Expand Down
3 changes: 3 additions & 0 deletions src/lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,9 @@ impl Translator {
Store::Uplay => "store-uplay",
Store::OtherHome => "store-other-home",
Store::OtherWine => "store-other-wine",
Store::OtherWindows => "store-other-windows",
Store::OtherLinux => "store-other-linux",
Store::OtherMac => "store-other-mac",
Store::Other => "store-other",
})
}
Expand Down
9 changes: 9 additions & 0 deletions src/resource/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ pub enum Store {
OtherHome,
#[serde(rename = "otherWine")]
OtherWine,
#[serde(rename = "otherWindows")]
OtherWindows,
#[serde(rename = "otherLinux")]
OtherLinux,
#[serde(rename = "otherMac")]
OtherMac,
#[default]
#[serde(other, rename = "other")]
Other,
Expand All @@ -122,6 +128,9 @@ impl Store {
Store::Uplay,
Store::OtherHome,
Store::OtherWine,
Store::OtherWindows,
Store::OtherLinux,
Store::OtherMac,
Store::Other,
];
}
Expand Down
44 changes: 44 additions & 0 deletions src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ pub fn parse_paths(
| Store::Uplay
| Store::OtherHome
| Store::OtherWine
| Store::OtherWindows
| Store::OtherLinux
| Store::OtherMac
| Store::Other => format!("{}/{}", &root_interpreted, install_dir),
},
)
Expand Down Expand Up @@ -375,6 +378,47 @@ pub fn parse_paths(
));
}

if root.store == Store::OtherWindows {
paths.insert((
path.replace(HOME, &format!("{}/Users/*", &root_interpreted))
.replace(STORE_USER_ID, "*")
.replace(OS_USER_NAME, "*")
.replace(WIN_APP_DATA, &format!("{}/Users/*/AppData/Roaming", &root_interpreted))
.replace(
WIN_LOCAL_APP_DATA,
&format!("{}/Users/*/AppData/Local", &root_interpreted),
)
.replace(WIN_DOCUMENTS, &format!("{}/Users/*/Documents", &root_interpreted))
.replace(WIN_PUBLIC, &format!("{}/Users/Public", &root_interpreted))
.replace(WIN_PROGRAM_DATA, &format!("{}/ProgramData", &root_interpreted))
.replace(WIN_DIR, &format!("{}/Windows", &root_interpreted)),
platform.is_case_sensitive(),
));
}
if root.store == Store::OtherLinux {
paths.insert((
path.replace(HOME, &format!("{}/home/*", &root_interpreted))
.replace(STORE_USER_ID, "*")
.replace(OS_USER_NAME, "*")
.replace(XDG_DATA, &format!("{}/home/*/.local/share", &root_interpreted))
.replace(XDG_CONFIG, &format!("{}/home/*/.config", &root_interpreted)),
platform.is_case_sensitive(),
));
}
if root.store == Store::OtherMac {
paths.insert((
path.replace(HOME, &format!("{}/Users/*", &root_interpreted))
.replace(STORE_USER_ID, "*")
.replace(OS_USER_NAME, "*")
.replace(XDG_DATA, &format!("{}/Users/*/Library", &root_interpreted))
.replace(
XDG_CONFIG,
&format!("{}/Users/*/Library/Preferences", &root_interpreted),
),
platform.is_case_sensitive(),
));
}

if Os::HOST != Os::Windows {
if let Some(flatpak_id) = ids.and_then(|x| x.flatpak.as_ref()) {
paths.insert((
Expand Down

0 comments on commit da57555

Please sign in to comment.