Skip to content

Commit

Permalink
Merge pull request #98 from /issues/75
Browse files Browse the repository at this point in the history
Issues/75
  • Loading branch information
GedasFX authored Aug 31, 2024
2 parents 42c4cef + b946f30 commit 3f01962
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 14 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,24 @@ example:
additional_sync_args=--onedrive-av-override
```

### Custom sync root

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 `/`**

Example, where 2 symlinks are created:

```bash
cd /home/deck/syncs
ln -s /run/media/mmcblk0p1/Emulation/saves/ "$(pwd)/emulation-saves"
ln -s "/home/deck/homebrew/settings/decky-cloud-save/" "$(pwd)/dcs-config"
```

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.

## Acknowledgments

Thank you to:
* [Emiliopg91](https://github.com/Emiliopg91), [NL-TCH](https://github.com/NL-TCH) for bi-sync support!
* [AkazaRenn](https://github.com/AkazaRenn), for various support!
* [Decky Homebrew Community](https://github.com/SteamDeckHomebrew) for assistance with development!
* [rclone](https://rclone.org/) for making this plugin possible!
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "decky-cloud-save",
"version": "1.4.1",
"version": "1.4.2",
"description": "Manage cloud saves for games that do not support it in [current year].",
"scripts": {
"build": "shx rm -rf dist && rollup -c",
Expand Down
2 changes: 2 additions & 0 deletions py_modules/plugin_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,5 @@ def migrate():
set_config("toast_auto_sync", "true")
if not any(e[0] == "additional_sync_args" for e in config):
set_config("additional_sync_args", "")
if not any(e[0] == "sync_root" for e in config):
set_config("sync_root", "/")
6 changes: 6 additions & 0 deletions py_modules/rclone_setup_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ async def test_syncpath(self, path: str):
Returns:
int | str: The number of files if it's a directory, '9000+' if it exceeds the limit, or 0 if it's a file.
"""
if not path.startswith(plugin_config.get_config_item("sync_root", "/")):
raise Exception("Selection is outside of sync root.")

if path.endswith("/**"):
scan_single_dir = False
path = path[:-3]
Expand Down Expand Up @@ -154,6 +157,9 @@ async def add_syncpath(self, path: str, file: str):
"""
decky_plugin.logger.info("Adding Path to Sync: '%s', %s", path, file)

# Replace the beginning of path to replace the root.
path = path.replace(plugin_config.get_config_item("sync_root", "/"), "/", 1)

file = plugin_config.cfg_syncpath_excludes_file if file == "excludes" else plugin_config.cfg_syncpath_includes_file

with open(file, "r") as f:
Expand Down
3 changes: 2 additions & 1 deletion py_modules/rclone_sync_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async def sync_now(self, winner: str, resync: bool):

bisync_enabled = plugin_config.get_config_item("bisync_enabled", "false") == "true"
destination_path = plugin_config.get_config_item("destination_directory", "decky-cloud-save")
sync_root = plugin_config.get_config_item("sync_root", "/")

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

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

args.extend(["/", f"backend:{destination_path}", "--filter-from",
args.extend([sync_root, f"backend:{destination_path}", "--filter-from",
plugin_config.cfg_syncpath_filter_file, "--copy-links"])
if bisync_enabled:
if resync:
Expand Down
2 changes: 1 addition & 1 deletion src/components/AddNewPathButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ButtonItem, showContextMenu, Menu, MenuItem, FilePickerRes, showModal,
import { useState } from "react";
import { PageProps } from "../helpers/types";
import { Toast } from "../helpers/toast";
import { Translator } from "../helpers/translator"
import { Translator } from "../helpers/translator";

export default function AddNewPathButton({ serverApi, onPathAdded, file }: PageProps<{ onPathAdded?: () => void; file: "includes" | "excludes" }>) {
const [buttonDisabled, setButtonDisabled] = useState(false);
Expand Down
16 changes: 5 additions & 11 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,12 @@ function syncGame(e: LifetimeNotification) {
}

function shouldSync(gameInfo: any) {
// Steam Games == 1
if (gameInfo?.app_type === 1) {
// Steam Cloud Enabled
if (gameInfo?.local_per_client_data?.cloud_status === 1) {
Logger.info("Steam game without Steam Cloud, proceeding");
return true;
} else {
Logger.info("Steam game with Steam Cloud, skipping");
return false;
}
if (gameInfo?.store_category.includes(23)) {
// 23 - Cloud Save
Logger.info("Steam game with Steam Cloud, skipping");
return false;
} else {
Logger.info("Non Steam game, proceeding");
Logger.info("Non Steam game, or game without Steam Cloud, proceeding");
return true;
}
}

0 comments on commit 3f01962

Please sign in to comment.