|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -from typing import TYPE_CHECKING, Dict, Optional |
| 3 | +from typing import TYPE_CHECKING, Optional |
4 | 4 |
|
5 | 5 | if TYPE_CHECKING: |
6 | 6 | from pathlib import Path |
7 | 7 |
|
8 | | - from datashuttle.utils.custom_types import ( |
9 | | - OverwriteExistingFiles, |
10 | | - ) |
| 8 | + from datashuttle.configs.configs_class import Configs |
11 | 9 |
|
12 | 10 | import yaml |
13 | 11 |
|
14 | 12 | from datashuttle.configs import canonical_folders |
15 | | -from datashuttle.utils import rclone_encryption, utils |
| 13 | +from datashuttle.utils import rclone_encryption |
16 | 14 |
|
17 | 15 |
|
18 | 16 | class RCloneConfigs: |
19 | 17 | """Class to manage the RClone configuration file. |
20 | 18 |
|
21 | 19 | This is a file that RClone creates to hold all information about local and |
22 | | - remote transfer targets. For example, the ssh RClone config holds the private key. |
| 20 | + central transfer targets. For example, the SSH RClone config holds the private key, |
| 21 | + the GDrive rclone config holds the access token, etc. |
23 | 22 |
|
24 | 23 | In datashuttle, local filesystem configs uses the Rclone default configuration file, |
25 | | - that RClone manages. However, remote transfers to ssh, aws and gdrive are held in |
26 | | - separate config files (set using RClone's --config argument). Then being separate |
27 | | - means these files can be separately encrypted. |
| 24 | + that RClone manages, for backwards comatability reasons. However, SSH, AWS and GDrive |
| 25 | + configs are stored in separate config files (set using RClone's --config argument). |
| 26 | + Then being separate means these files can be separately encrypted. |
28 | 27 |
|
29 | 28 | This class tracks the state on whether a RClone config is encrypted, as well |
30 | 29 | as provides the default names for the rclone conf (e.g. central_<project_name>_<connection_method>). |
31 | 30 |
|
32 | 31 | Parameters |
33 | 32 | ---------- |
| 33 | + datashuttle_configs |
| 34 | + Parent Configs class. |
| 35 | +
|
34 | 36 | config_base_class |
35 | 37 | Path to the datashuttle configs folder where all configs for the project are stored. |
36 | 38 |
|
37 | 39 | """ |
38 | 40 |
|
39 | | - def __init__(self, datashuttle_configs, config_base_path): |
| 41 | + def __init__(self, datashuttle_configs: Configs, config_base_path: Path): |
40 | 42 | """Construct the class.""" |
41 | 43 | self.datashuttle_configs = datashuttle_configs |
42 | 44 | self.rclone_encryption_state_file_path = ( |
@@ -73,8 +75,9 @@ def load_rclone_config_is_encrypted(self) -> dict: |
73 | 75 | def set_rclone_config_encryption_state(self, value: bool) -> None: |
74 | 76 | """Store the current state of the rclone config encryption for the `connection_method`. |
75 | 77 |
|
76 | | - Note that this is stored to disk each call (rather than tracked locally) to ensure |
77 | | - it is updated live if updated through the Python API while the TUI is also running. |
| 78 | + Note that this is stored to disk each call (rather than tracked in memory) |
| 79 | + to ensure it is updated properly if changed through the Python API |
| 80 | + while the TUI is also running. |
78 | 81 | """ |
79 | 82 | assert rclone_encryption.connection_method_requires_encryption( |
80 | 83 | self.datashuttle_configs["connection_method"] |
@@ -119,27 +122,6 @@ def get_rclone_central_connection_config_filepath(self) -> Path: |
119 | 122 | / f"{self.get_rclone_config_name()}.conf" |
120 | 123 | ) |
121 | 124 |
|
122 | | - def make_rclone_transfer_options( |
123 | | - self, overwrite_existing_files: OverwriteExistingFiles, dry_run: bool |
124 | | - ) -> Dict: |
125 | | - """Create a dictionary of rclone transfer options.""" |
126 | | - allowed_overwrite = ["never", "always", "if_source_newer"] |
127 | | - |
128 | | - if overwrite_existing_files not in allowed_overwrite: |
129 | | - utils.log_and_raise_error( |
130 | | - f"`overwrite_existing_files` not " |
131 | | - f"recognised, must be one of: " |
132 | | - f"{allowed_overwrite}", |
133 | | - ValueError, |
134 | | - ) |
135 | | - |
136 | | - return { |
137 | | - "overwrite_existing_files": overwrite_existing_files, |
138 | | - "show_transfer_progress": True, |
139 | | - "transfer_verbosity": "vv", |
140 | | - "dry_run": dry_run, |
141 | | - } |
142 | | - |
143 | 125 | def delete_existing_rclone_config_file(self) -> None: |
144 | 126 | """Delete the Rclone config file if it exists.""" |
145 | 127 | rclone_config_filepath = ( |
|
0 commit comments