rclone-api 1.0.69__py2.py3-none-any.whl → 1.0.70__py2.py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rclone-api might be problematic. Click here for more details.
- rclone_api/diff_walk.py +70 -90
- rclone_api/dir.py +1 -1
- {rclone_api-1.0.69.dist-info → rclone_api-1.0.70.dist-info}/METADATA +1 -1
- {rclone_api-1.0.69.dist-info → rclone_api-1.0.70.dist-info}/RECORD +8 -8
- {rclone_api-1.0.69.dist-info → rclone_api-1.0.70.dist-info}/LICENSE +0 -0
- {rclone_api-1.0.69.dist-info → rclone_api-1.0.70.dist-info}/WHEEL +0 -0
- {rclone_api-1.0.69.dist-info → rclone_api-1.0.70.dist-info}/entry_points.txt +0 -0
- {rclone_api-1.0.69.dist-info → rclone_api-1.0.70.dist-info}/top_level.txt +0 -0
rclone_api/diff_walk.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
import time
|
1
2
|
from concurrent.futures import ThreadPoolExecutor
|
2
|
-
from queue import Queue
|
3
|
+
from queue import Empty, Queue
|
3
4
|
from threading import Thread
|
4
5
|
from typing import Generator
|
5
6
|
|
@@ -13,96 +14,71 @@ _MAX_OUT_QUEUE_SIZE = 50
|
|
13
14
|
|
14
15
|
# ONLY Works from src -> dst diffing.
|
15
16
|
def _async_diff_dir_walk_task(
|
16
|
-
src: Dir, dst: Dir, max_depth: int, out_queue: Queue[Dir | None], reverse
|
17
|
+
src: Dir, dst: Dir, max_depth: int, out_queue: Queue[Dir | None], reverse
|
17
18
|
) -> None:
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
# # stack.append((child, depth - 1 if depth > 0 else depth))
|
44
|
-
# next_depth = depth - 1 if depth > 0 else depth
|
45
|
-
# _walk_runner_depth_first(
|
46
|
-
# subdir, next_depth, out_queue, reverse=reverse
|
47
|
-
# )
|
48
|
-
# out_queue.put(dirlisting)
|
49
|
-
|
50
|
-
# for subdir in dst_dir_listing.dirs:
|
51
|
-
# subdir.to_string(include_remote=False)
|
52
|
-
# walk_runner_depth_first()
|
53
|
-
|
54
|
-
# find elements missing on dst
|
55
|
-
# missing_on_dst: set[Dir] = set(src_dir_listing.dirs) - set(
|
56
|
-
# dst_dir_listing.dirs
|
57
|
-
# )
|
58
|
-
# exists_on_dst: set[Dir] = set(src_dir_listing.dirs) - missing_on_dst
|
59
|
-
|
60
|
-
dst_files: list[str] = [d.name for d in dst_dir_listing.dirs]
|
61
|
-
src_files: list[str] = [d.name for d in src_dir_listing.dirs]
|
62
|
-
|
63
|
-
dst_files_set: set[str] = set(dst_files)
|
64
|
-
# src_files_set: set[str] = set(src_files)
|
65
|
-
|
66
|
-
# print(f"src_files: {src_files}")
|
67
|
-
# print(f"dst_files: {dst_files}")
|
68
|
-
|
69
|
-
matching_dirs: list[str] = []
|
70
|
-
|
71
|
-
for file in src_files:
|
72
|
-
if file not in dst_files_set:
|
73
|
-
# print(f"missing dir on src: {file}")
|
74
|
-
queue_dir_listing: Queue[DirListing | None] = Queue()
|
75
|
-
walk_runner_depth_first(
|
76
|
-
dir=curr_src,
|
77
|
-
max_depth=max_depth,
|
78
|
-
out_queue=queue_dir_listing,
|
79
|
-
reverse=reverse,
|
80
|
-
)
|
81
|
-
while dirlisting := queue_dir_listing.get():
|
82
|
-
if dirlisting is None:
|
83
|
-
break
|
84
|
-
# print(f"dirlisting: {dirlisting}")
|
85
|
-
for d in dirlisting.dirs:
|
86
|
-
out_queue.put(d)
|
87
|
-
else:
|
88
|
-
matching_dirs.append(file)
|
89
|
-
|
90
|
-
for matching_dir in matching_dirs:
|
91
|
-
# print(f"matching dir: {matching_dir}")
|
92
|
-
_async_diff_dir_walk_task(
|
93
|
-
src=curr_src / matching_dir,
|
94
|
-
dst=curr_dst / matching_dir,
|
95
|
-
max_depth=max_depth,
|
96
|
-
out_queue=out_queue,
|
19
|
+
curr_src, curr_dst = src, dst
|
20
|
+
with ThreadPoolExecutor(max_workers=2) as executor:
|
21
|
+
# src_dir_listing = src.ls(listing_option=ListingOption.DIRS_ONLY)
|
22
|
+
# dst_dir_listing = dst.ls(listing_option=ListingOption.DIRS_ONLY)
|
23
|
+
t1 = executor.submit(
|
24
|
+
src.ls, listing_option=ListingOption.DIRS_ONLY, reverse=reverse
|
25
|
+
)
|
26
|
+
t2 = executor.submit(
|
27
|
+
dst.ls, listing_option=ListingOption.DIRS_ONLY, reverse=reverse
|
28
|
+
)
|
29
|
+
src_dir_listing: DirListing = t1.result()
|
30
|
+
dst_dir_listing: DirListing = t2.result()
|
31
|
+
next_depth = max_depth - 1 if max_depth > 0 else max_depth
|
32
|
+
dst_files: list[str] = [d.name for d in dst_dir_listing.dirs]
|
33
|
+
src_files: list[str] = [d.name for d in src_dir_listing.dirs]
|
34
|
+
dst_files_set: set[str] = set(dst_files)
|
35
|
+
matching_dirs: list[str] = []
|
36
|
+
for file in src_files:
|
37
|
+
if file not in dst_files_set:
|
38
|
+
# print(f"missing dir on src: {file}")
|
39
|
+
queue_dir_listing: Queue[DirListing | None] = Queue()
|
40
|
+
if next_depth > 0 or next_depth == -1:
|
41
|
+
walk_runner_depth_first(
|
42
|
+
dir=curr_src,
|
43
|
+
out_queue=queue_dir_listing,
|
97
44
|
reverse=reverse,
|
45
|
+
max_depth=next_depth,
|
98
46
|
)
|
99
|
-
|
100
|
-
|
101
|
-
|
47
|
+
while dirlisting := queue_dir_listing.get():
|
48
|
+
if dirlisting is None:
|
49
|
+
break
|
50
|
+
# print(f"dirlisting: {dirlisting}")
|
51
|
+
for d in dirlisting.dirs:
|
52
|
+
out_queue.put(d)
|
53
|
+
else:
|
54
|
+
matching_dirs.append(file)
|
55
|
+
|
56
|
+
for matching_dir in matching_dirs:
|
57
|
+
# print(f"matching dir: {matching_dir}")
|
58
|
+
if next_depth > 0 or next_depth == -1:
|
59
|
+
src_next = curr_src / matching_dir
|
60
|
+
dst_next = curr_dst / matching_dir
|
61
|
+
_async_diff_dir_walk_task(
|
62
|
+
src=src_next,
|
63
|
+
dst=dst_next,
|
64
|
+
max_depth=next_depth,
|
65
|
+
out_queue=out_queue,
|
66
|
+
reverse=reverse,
|
67
|
+
)
|
68
|
+
|
69
|
+
|
70
|
+
def async_diff_dir_walk_task(
|
71
|
+
src: Dir, dst: Dir, max_depth: int, out_queue: Queue[Dir | None], reverse=False
|
72
|
+
) -> None:
|
73
|
+
try:
|
74
|
+
_async_diff_dir_walk_task(src, dst, max_depth, out_queue, reverse)
|
75
|
+
except Exception:
|
102
76
|
import _thread
|
103
77
|
|
104
|
-
out_queue.put(None)
|
105
78
|
_thread.interrupt_main()
|
79
|
+
raise
|
80
|
+
finally:
|
81
|
+
out_queue.put(None)
|
106
82
|
|
107
83
|
|
108
84
|
def diff_walk(
|
@@ -125,7 +101,7 @@ def diff_walk(
|
|
125
101
|
out_queue: Queue[Dir | None] = Queue(maxsize=_MAX_OUT_QUEUE_SIZE)
|
126
102
|
|
127
103
|
def task() -> None:
|
128
|
-
|
104
|
+
async_diff_dir_walk_task(src, dst, max_depth, out_queue, reverse=reverse)
|
129
105
|
|
130
106
|
worker = Thread(
|
131
107
|
target=task,
|
@@ -133,10 +109,14 @@ def diff_walk(
|
|
133
109
|
)
|
134
110
|
worker.start()
|
135
111
|
|
136
|
-
while
|
137
|
-
|
138
|
-
|
139
|
-
|
112
|
+
while True:
|
113
|
+
try:
|
114
|
+
dirlisting = out_queue.get_nowait()
|
115
|
+
if dirlisting is None:
|
116
|
+
break
|
117
|
+
yield dirlisting
|
118
|
+
except Empty:
|
119
|
+
time.sleep(0.1)
|
140
120
|
|
141
121
|
worker.join()
|
142
122
|
except KeyboardInterrupt:
|
rclone_api/dir.py
CHANGED
@@ -5,8 +5,8 @@ rclone_api/config.py,sha256=tP6cU9DnCCEIRc_KP9HPur1jFLLg2QGFSxNwFm6_MVw,118
|
|
5
5
|
rclone_api/convert.py,sha256=Mx9Qo7zhkOedJd8LdhPvNGHp8znJzOk4f_2KWnoGc78,1012
|
6
6
|
rclone_api/deprecated.py,sha256=qWKpnZdYcBK7YQZKuVoWWXDwi-uqiAtbjgPcci_efow,590
|
7
7
|
rclone_api/diff.py,sha256=ggdDLUZxa13jMcPzKBcwAElmPCNWMOSR89D4yhpO74M,5264
|
8
|
-
rclone_api/diff_walk.py,sha256=
|
9
|
-
rclone_api/dir.py,sha256=
|
8
|
+
rclone_api/diff_walk.py,sha256=fnCjzenKBBocu6sEd9CDEcwNqCUYwz3rZsxUuKNaYEg,4049
|
9
|
+
rclone_api/dir.py,sha256=BuXPd-bAvZund8k7mXjvx_UylsPFwbWq2zaUdflTX04,3520
|
10
10
|
rclone_api/dir_listing.py,sha256=9Qqf2SUswrOEkyqmaH23V51I18X6ePiXb9B1vUwRF5o,1571
|
11
11
|
rclone_api/exec.py,sha256=1ovvaMXDEfLiT7BrYZyE85u_yFhEUwUNW3jPOzqknR8,1023
|
12
12
|
rclone_api/file.py,sha256=YtR5Y6c0YfXTS-sReOy2UgiSnafcAeO6b2hnbojBQD4,1423
|
@@ -21,9 +21,9 @@ rclone_api/util.py,sha256=_cvmHcJPRl2yXw4zgZiop3z-riA_8Ek6S5NDPw8cqSY,4198
|
|
21
21
|
rclone_api/walk.py,sha256=ndWV7WBVQLbpZu3HuJrAe1cXcmQVjT9_YPsbat158bQ,3231
|
22
22
|
rclone_api/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
|
23
23
|
rclone_api/cmd/list_files.py,sha256=x8FHODEilwKqwdiU1jdkeJbLwOqUkUQuDWPo2u_zpf0,741
|
24
|
-
rclone_api-1.0.
|
25
|
-
rclone_api-1.0.
|
26
|
-
rclone_api-1.0.
|
27
|
-
rclone_api-1.0.
|
28
|
-
rclone_api-1.0.
|
29
|
-
rclone_api-1.0.
|
24
|
+
rclone_api-1.0.70.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
25
|
+
rclone_api-1.0.70.dist-info/METADATA,sha256=73129SIcLoTZ3R35zB0vuZZ65SC0RBttGk1LtPARAx8,4489
|
26
|
+
rclone_api-1.0.70.dist-info/WHEEL,sha256=9Hm2OB-j1QcCUq9Jguht7ayGIIZBRTdOXD1qg9cCgPM,109
|
27
|
+
rclone_api-1.0.70.dist-info/entry_points.txt,sha256=XUoTX3m7CWxdj2VAKhEuO0NMOfX2qf-OcEDFwdyk9ZE,72
|
28
|
+
rclone_api-1.0.70.dist-info/top_level.txt,sha256=EvZ7uuruUpe9RiUyEp25d1Keq7PWYNT0O_-mr8FCG5g,11
|
29
|
+
rclone_api-1.0.70.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|