Skip to content

Commit bf72386

Browse files
committed
prevent hitting ARG_MAX limit
1 parent 73b7bbf commit bf72386

File tree

4 files changed

+30
-22
lines changed

4 files changed

+30
-22
lines changed

library/multidb/allocate_torrents.py

+19-17
Original file line numberDiff line numberDiff line change
@@ -242,23 +242,25 @@ def allocate_torrents():
242242
ssh.connect(d["host"])
243243
setattr(ssh, "host", d["host"])
244244

245-
remote_processes.cmd(
246-
ssh,
247-
"python3",
248-
"-m",
249-
"library",
250-
"torrents-start",
251-
*argparse_utils.forward_arggroups(args, arggroups.torrents_start),
252-
*argparse_utils.forward_arggroups(args, arggroups.qBittorrent),
253-
*argparse_utils.forward_arggroups(
254-
args,
255-
arggroups.qBittorrent_paths,
256-
download_drive=d["mountpoint"],
257-
),
258-
*torrent_files,
259-
local_files=torrent_files,
260-
# cwd="lb", # debug
261-
)
245+
torrent_files_chunks = iterables.chunks(torrent_files, 128)
246+
for torrent_files_chunk in torrent_files_chunks:
247+
remote_processes.cmd(
248+
ssh,
249+
"python3",
250+
"-m",
251+
"library",
252+
"torrents-start",
253+
*argparse_utils.forward_arggroups(args, arggroups.torrents_start),
254+
*argparse_utils.forward_arggroups(args, arggroups.qBittorrent),
255+
*argparse_utils.forward_arggroups(
256+
args,
257+
arggroups.qBittorrent_paths,
258+
download_drive=d["mountpoint"],
259+
),
260+
*torrent_files_chunk,
261+
local_files=torrent_files_chunk,
262+
# cwd="lb", # debug
263+
)
262264

263265
if args.delete_torrent:
264266
for path in torrent_files:

library/playback/torrents_info.py

+2
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ def filter_torrents_by_criteria(args, torrents):
166166
torrents = [t for t in torrents if args.priority(t.priority)]
167167
if "progress" not in args.defaults:
168168
torrents = [t for t in torrents if args.progress(t.progress)]
169+
if "downloaded" not in args.defaults:
170+
torrents = [t for t in torrents if args.downloaded(t.downloaded)]
169171
if "uploaded" not in args.defaults:
170172
torrents = [t for t in torrents if args.uploaded(t.uploaded)]
171173
if "remaining" not in args.defaults:

library/utils/arggroups.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,9 @@ def qBittorrent_torrents(parent_parser):
20312031
action="append",
20322032
help="""Include torrents constrained by average file sizes (uses the same syntax as fd-find)""",
20332033
)
2034-
parser.add_argument("--file-count", "--files", action="append", help="Include torrents constrained by total file counts")
2034+
parser.add_argument(
2035+
"--file-count", "--files", action="append", help="Include torrents constrained by total file counts"
2036+
)
20352037
parser.add_argument("--seeders", action="append", help="Include torrents with N seeders")
20362038
parser.add_argument("--leechers", action="append", help="Include torrents with N leechers")
20372039
parser.add_argument("--time-added", action="append", help="Include torrents with N time since added")
@@ -2045,6 +2047,7 @@ def qBittorrent_torrents(parent_parser):
20452047
parser.add_argument("--priority", action="append", help="Include torrents with N priority")
20462048
parser.add_argument("--progress", action="append", help="Include torrents with N%% progress")
20472049
parser.add_argument("--remaining", action="append", help="Include torrents with N bytes remaining")
2050+
parser.add_argument("--downloaded", action="append", help="Include torrents with N bytes downloaded")
20482051
parser.add_argument("--uploaded", action="append", help="Include torrents with N bytes uploaded")
20492052
parser.add_argument("--ratio", action="append", help="Include torrents with N ratio")
20502053

@@ -2069,9 +2072,7 @@ def qBittorrent_torrents(parent_parser):
20692072
help="Include uploading torrents",
20702073
)
20712074

2072-
parser.add_argument(
2073-
"--file-counts", action="store_true", help="Include file counts column (a bit slow)"
2074-
)
2075+
parser.add_argument("--file-counts", action="store_true", help="Include file counts column (a bit slow)")
20752076
parser.add_argument("--trackers", action="store_true", help="Include tracker column")
20762077
parser.add_argument("--status", "--state", action="store_true", help="Include state column")
20772078
parser.add_argument("--paths", action="store_true", help="Include downloading/seeding path columns")
@@ -2097,6 +2098,7 @@ def qBittorrent_torrents(parent_parser):
20972098
def qBittorrent_torrents_post(args):
20982099
args.sizes = sql_utils.parse_human_to_lambda(nums.human_to_bytes, args.sizes)
20992100
args.remaining = sql_utils.parse_human_to_lambda(nums.human_to_bytes, args.remaining)
2101+
args.downloaded = sql_utils.parse_human_to_lambda(nums.human_to_bytes, args.downloaded)
21002102
args.uploaded = sql_utils.parse_human_to_lambda(nums.human_to_bytes, args.uploaded)
21012103
args.avg_sizes = sql_utils.parse_human_to_lambda(nums.human_to_bytes, args.avg_sizes)
21022104
args.file_count = sql_utils.parse_human_to_lambda(int, args.file_count)

library/utils/remote_processes.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def print_std(s, is_success):
5656
returncode = stdout.channel.recv_exit_status()
5757

5858
host = getattr(ssh, "host", None)
59-
if host:
59+
if host: # for logging purposes
6060
command = " ".join(["ssh", host, command])
6161

6262
r = subprocess.CompletedProcess(command, returncode, stdout.read().decode(), stderr.read().decode())
@@ -80,6 +80,8 @@ def print_std(s, is_success):
8080
log.warning("[%s] exited %s", command, r.returncode)
8181

8282
if strict:
83+
if error_verbosity <= 1:
84+
log.error("[%s] exited %s", command, r.returncode)
8385
r.check_returncode()
8486

8587
return r

0 commit comments

Comments
 (0)