rclone-api 1.3.12__py2.py3-none-any.whl → 1.3.14__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rclone_api/cmd/save_to_db.py +6 -3
- rclone_api/db/db.py +12 -3
- {rclone_api-1.3.12.dist-info → rclone_api-1.3.14.dist-info}/METADATA +1 -1
- {rclone_api-1.3.12.dist-info → rclone_api-1.3.14.dist-info}/RECORD +8 -8
- {rclone_api-1.3.12.dist-info → rclone_api-1.3.14.dist-info}/LICENSE +0 -0
- {rclone_api-1.3.12.dist-info → rclone_api-1.3.14.dist-info}/WHEEL +0 -0
- {rclone_api-1.3.12.dist-info → rclone_api-1.3.14.dist-info}/entry_points.txt +0 -0
- {rclone_api-1.3.12.dist-info → rclone_api-1.3.14.dist-info}/top_level.txt +0 -0
rclone_api/cmd/save_to_db.py
CHANGED
|
@@ -28,17 +28,18 @@ class Args:
|
|
|
28
28
|
config: Path
|
|
29
29
|
path: str
|
|
30
30
|
db_url: str
|
|
31
|
+
fast_list: bool
|
|
31
32
|
|
|
32
33
|
def __post_init__(self):
|
|
33
34
|
if not self.config.exists():
|
|
34
35
|
raise FileNotFoundError(f"Config file not found: {self.config}")
|
|
35
36
|
|
|
36
37
|
|
|
37
|
-
def fill_db(rclone: Rclone, path: str):
|
|
38
|
+
def fill_db(rclone: Rclone, path: str, fast_list: bool) -> None:
|
|
38
39
|
"""List files in a remote path."""
|
|
39
40
|
# db = DB(_db_url_from_env_or_raise())
|
|
40
41
|
db_url = _db_url_from_env_or_raise()
|
|
41
|
-
rclone.save_to_db(src=path, db_url=db_url, fast_list=
|
|
42
|
+
rclone.save_to_db(src=path, db_url=db_url, fast_list=fast_list)
|
|
42
43
|
|
|
43
44
|
|
|
44
45
|
def _parse_args() -> Args:
|
|
@@ -47,12 +48,14 @@ def _parse_args() -> Args:
|
|
|
47
48
|
"--config", help="Path to rclone config file", type=Path, default="rclone.conf"
|
|
48
49
|
)
|
|
49
50
|
parser.add_argument("--db", help="Database URL", type=str, default=None)
|
|
51
|
+
parser.add_argument("--fast-list", help="Use fast list", action="store_true")
|
|
50
52
|
parser.add_argument("path", help="Remote path to list")
|
|
51
53
|
tmp = parser.parse_args()
|
|
52
54
|
return Args(
|
|
53
55
|
config=tmp.config,
|
|
54
56
|
path=tmp.path,
|
|
55
57
|
db_url=tmp.db if tmp.db is not None else _db_url_from_env_or_raise(),
|
|
58
|
+
fast_list=tmp.fast_list,
|
|
56
59
|
)
|
|
57
60
|
|
|
58
61
|
|
|
@@ -61,7 +64,7 @@ def main() -> int:
|
|
|
61
64
|
args = _parse_args()
|
|
62
65
|
path = args.path
|
|
63
66
|
rclone = Rclone(Path(args.config))
|
|
64
|
-
fill_db(rclone, path)
|
|
67
|
+
fill_db(rclone=rclone, path=path, fast_list=args.fast_list)
|
|
65
68
|
return 0
|
|
66
69
|
|
|
67
70
|
|
rclone_api/db/db.py
CHANGED
|
@@ -29,10 +29,19 @@ class DB:
|
|
|
29
29
|
db_path: Path to the database file
|
|
30
30
|
"""
|
|
31
31
|
self.db_path_url = db_path_url
|
|
32
|
-
self.engine = create_engine(db_path_url)
|
|
33
32
|
|
|
34
|
-
#
|
|
35
|
-
|
|
33
|
+
# When running multiple commands in parallel, the database connection may fail once
|
|
34
|
+
# when the database is first populated.
|
|
35
|
+
retries = 2
|
|
36
|
+
for _ in range(retries):
|
|
37
|
+
try:
|
|
38
|
+
self.engine = create_engine(db_path_url)
|
|
39
|
+
SQLModel.metadata.create_all(self.engine)
|
|
40
|
+
break
|
|
41
|
+
except Exception as e:
|
|
42
|
+
print(f"Failed to connect to database. Retrying... {e}")
|
|
43
|
+
else:
|
|
44
|
+
raise Exception("Failed to connect to database.")
|
|
36
45
|
self._cache: dict[str, DBRepo] = {}
|
|
37
46
|
self._cache_lock = Lock()
|
|
38
47
|
|
|
@@ -27,9 +27,9 @@ rclone_api/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8
|
|
|
27
27
|
rclone_api/cmd/analyze.py,sha256=RHbvk1G5ZUc3qLqlm1AZEyQzd_W_ZjcbCNDvW4YpTKQ,1252
|
|
28
28
|
rclone_api/cmd/copy_large_s3.py,sha256=nOpAUAQN1mJnf4EIZCh4OVCW7Q4_EXJeLFVe6r_9rZA,3369
|
|
29
29
|
rclone_api/cmd/list_files.py,sha256=x8FHODEilwKqwdiU1jdkeJbLwOqUkUQuDWPo2u_zpf0,741
|
|
30
|
-
rclone_api/cmd/save_to_db.py,sha256=
|
|
30
|
+
rclone_api/cmd/save_to_db.py,sha256=ylvnhg_yzexM-m6Zr7XDiswvoDVSl56ELuFAdb9gqBY,1957
|
|
31
31
|
rclone_api/db/__init__.py,sha256=OSRUdnSWUlDTOHmjdjVmxYTUNpTbtaJ5Ll9sl-PfZg0,40
|
|
32
|
-
rclone_api/db/db.py,sha256=
|
|
32
|
+
rclone_api/db/db.py,sha256=7jGyl9X0WUCgZ3pYbJKrZe6FwtUrMOwRIXG8tNH0RWs,10341
|
|
33
33
|
rclone_api/db/models.py,sha256=unKEiu8l4R4UAEoncEbOHEda227DpXm-cWwRV6vwJXE,1657
|
|
34
34
|
rclone_api/experimental/flags.py,sha256=qCVD--fSTmzlk9hloRLr0q9elzAOFzPsvVpKM3aB1Mk,2739
|
|
35
35
|
rclone_api/experimental/flags_base.py,sha256=ajU_czkTcAxXYU-SlmiCfHY7aCQGHvpCLqJ-Z8uZLk0,2102
|
|
@@ -41,9 +41,9 @@ rclone_api/s3/chunk_types.py,sha256=oSWv8No9V3BeM7IcGnowyR2a7YrszdAXzEJlxaeZcp0,
|
|
|
41
41
|
rclone_api/s3/create.py,sha256=wgfkapv_j904CfKuWyiBIWJVxfAx_ftemFSUV14aT68,3149
|
|
42
42
|
rclone_api/s3/types.py,sha256=Elmh__gvZJyJyElYwMmvYZIBIunDJiTRAbEg21GmsRU,1604
|
|
43
43
|
rclone_api/s3/upload_file_multipart.py,sha256=d8ZWqO8n9wsqRF6JjmvAFmG1aCkFqdSB1L8yxe_5qiY,11669
|
|
44
|
-
rclone_api-1.3.
|
|
45
|
-
rclone_api-1.3.
|
|
46
|
-
rclone_api-1.3.
|
|
47
|
-
rclone_api-1.3.
|
|
48
|
-
rclone_api-1.3.
|
|
49
|
-
rclone_api-1.3.
|
|
44
|
+
rclone_api-1.3.14.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
|
45
|
+
rclone_api-1.3.14.dist-info/METADATA,sha256=MSDO9lcIfpcmAo76zfbOLx9ne5W1lIJfdsjO4UT8SJQ,4610
|
|
46
|
+
rclone_api-1.3.14.dist-info/WHEEL,sha256=rF4EZyR2XVS6irmOHQIJx2SUqXLZKRMUrjsg8UwN-XQ,109
|
|
47
|
+
rclone_api-1.3.14.dist-info/entry_points.txt,sha256=fJteOlYVwgX3UbNuL9jJ0zUTuX2O79JFAeNgK7Sw7EQ,255
|
|
48
|
+
rclone_api-1.3.14.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
|
|
49
|
+
rclone_api-1.3.14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|