Skip to content

Commit 3f01962

Browse files
authored
Merge pull request #98 from /issues/75
Issues/75
2 parents 42c4cef + b946f30 commit 3f01962

7 files changed

+32
-14
lines changed

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,24 @@ example:
144144
additional_sync_args=--onedrive-av-override
145145
```
146146

147+
### Custom sync root
148+
149+
By default the sync root is `/` for simplicity. If having it causes issues, you can change it to another place and create symlinks. Set `plugin.properties` value `sync_root` to be whatever you wish (e.g. `/home/deck/`). **IMPORTANT: This path must be absolute, and must end with a trailing `/`**
150+
151+
Example, where 2 symlinks are created:
152+
153+
```bash
154+
cd /home/deck/syncs
155+
ln -s /run/media/mmcblk0p1/Emulation/saves/ "$(pwd)/emulation-saves"
156+
ln -s "/home/deck/homebrew/settings/decky-cloud-save/" "$(pwd)/dcs-config"
157+
```
158+
159+
In `plugin.properties`, when root is set to `/home/deck`, we can sync the folder `syncs`, and it would show up as `emulation-saves`, and `dcs-config` on the configured cloud provider.
160+
147161
## Acknowledgments
148162

149163
Thank you to:
150164
* [Emiliopg91](https://github.com/Emiliopg91), [NL-TCH](https://github.com/NL-TCH) for bi-sync support!
165+
* [AkazaRenn](https://github.com/AkazaRenn), for various support!
151166
* [Decky Homebrew Community](https://github.com/SteamDeckHomebrew) for assistance with development!
152167
* [rclone](https://rclone.org/) for making this plugin possible!

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "decky-cloud-save",
3-
"version": "1.4.1",
3+
"version": "1.4.2",
44
"description": "Manage cloud saves for games that do not support it in [current year].",
55
"scripts": {
66
"build": "shx rm -rf dist && rollup -c",

py_modules/plugin_config.py

+2
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,5 @@ def migrate():
110110
set_config("toast_auto_sync", "true")
111111
if not any(e[0] == "additional_sync_args" for e in config):
112112
set_config("additional_sync_args", "")
113+
if not any(e[0] == "sync_root" for e in config):
114+
set_config("sync_root", "/")

py_modules/rclone_setup_manager.py

+6
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ async def test_syncpath(self, path: str):
124124
Returns:
125125
int | str: The number of files if it's a directory, '9000+' if it exceeds the limit, or 0 if it's a file.
126126
"""
127+
if not path.startswith(plugin_config.get_config_item("sync_root", "/")):
128+
raise Exception("Selection is outside of sync root.")
129+
127130
if path.endswith("/**"):
128131
scan_single_dir = False
129132
path = path[:-3]
@@ -154,6 +157,9 @@ async def add_syncpath(self, path: str, file: str):
154157
"""
155158
decky_plugin.logger.info("Adding Path to Sync: '%s', %s", path, file)
156159

160+
# Replace the beginning of path to replace the root.
161+
path = path.replace(plugin_config.get_config_item("sync_root", "/"), "/", 1)
162+
157163
file = plugin_config.cfg_syncpath_excludes_file if file == "excludes" else plugin_config.cfg_syncpath_includes_file
158164

159165
with open(file, "r") as f:

py_modules/rclone_sync_manager.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ async def sync_now(self, winner: str, resync: bool):
3232

3333
bisync_enabled = plugin_config.get_config_item("bisync_enabled", "false") == "true"
3434
destination_path = plugin_config.get_config_item("destination_directory", "decky-cloud-save")
35+
sync_root = plugin_config.get_config_item("sync_root", "/")
3536

3637
additional_args = [x for x in plugin_config.get_config_item("additional_sync_args", "").split(' ') if x]
3738

@@ -42,7 +43,7 @@ async def sync_now(self, winner: str, resync: bool):
4243
args.extend(["copy"])
4344
decky_plugin.logger.debug("Using copy")
4445

45-
args.extend(["/", f"backend:{destination_path}", "--filter-from",
46+
args.extend([sync_root, f"backend:{destination_path}", "--filter-from",
4647
plugin_config.cfg_syncpath_filter_file, "--copy-links"])
4748
if bisync_enabled:
4849
if resync:

src/components/AddNewPathButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ButtonItem, showContextMenu, Menu, MenuItem, FilePickerRes, showModal,
22
import { useState } from "react";
33
import { PageProps } from "../helpers/types";
44
import { Toast } from "../helpers/toast";
5-
import { Translator } from "../helpers/translator"
5+
import { Translator } from "../helpers/translator";
66

77
export default function AddNewPathButton({ serverApi, onPathAdded, file }: PageProps<{ onPathAdded?: () => void; file: "includes" | "excludes" }>) {
88
const [buttonDisabled, setButtonDisabled] = useState(false);

src/index.tsx

+5-11
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,12 @@ function syncGame(e: LifetimeNotification) {
7676
}
7777

7878
function shouldSync(gameInfo: any) {
79-
// Steam Games == 1
80-
if (gameInfo?.app_type === 1) {
81-
// Steam Cloud Enabled
82-
if (gameInfo?.local_per_client_data?.cloud_status === 1) {
83-
Logger.info("Steam game without Steam Cloud, proceeding");
84-
return true;
85-
} else {
86-
Logger.info("Steam game with Steam Cloud, skipping");
87-
return false;
88-
}
79+
if (gameInfo?.store_category.includes(23)) {
80+
// 23 - Cloud Save
81+
Logger.info("Steam game with Steam Cloud, skipping");
82+
return false;
8983
} else {
90-
Logger.info("Non Steam game, proceeding");
84+
Logger.info("Non Steam game, or game without Steam Cloud, proceeding");
9185
return true;
9286
}
9387
}

0 commit comments

Comments
 (0)