Skip to content

Commit a42df61

Browse files
committed
Rename 'subdir' parameter to 'path-starts-with'
1 parent 8cdb6a3 commit a42df61

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ Download QFieldCloud project files.
115115
qfieldcloud-cli download-files [OPTIONS] PROJECT_ID LOCAL_DIR
116116
117117
Options:
118-
--subdir TEXT Do not download the whole project, but only
119-
the subdirectory passed.
118+
--path-starts-with TEXT Do not download the whole project, but only
119+
the files which path starts with the string.
120120
121121
--exit-on-error / --no-exit-on-error
122122
If any project file download fails stop

src/bin/qfieldcloud-cli

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,18 @@ def list_files(ctx, project_id):
156156
@click.argument("project_id")
157157
@click.argument("local_dir")
158158
@click.option(
159-
"--subdir",
160-
help="Do not download the whole project, but only the subdirectory passed.",
159+
"--path-starts-with",
160+
help="Do not download the whole project, but only the files which path starts with the string.",
161161
)
162162
@click.option(
163163
"--exit-on-error/--no-exit-on-error",
164164
help="If any project file download fails stop downloading the rest. Default: False",
165165
)
166166
@click.pass_context
167-
def download_files(ctx, project_id, local_dir, subdir, exit_on_error):
167+
def download_files(ctx, project_id, local_dir, path_starts_with, exit_on_error):
168168
"""Download QFieldCloud project files."""
169169
files = ctx.obj["client"].download_files(
170-
project_id, local_dir, subdir, exit_on_error
170+
project_id, local_dir, path_starts_with, exit_on_error
171171
)
172172

173173
if ctx.obj["format_json"]:

src/qfieldcloud_sdk/sdk.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ def download_files(
6969
self,
7070
project_id: str,
7171
local_dir: str,
72-
subdir: str = None,
72+
path_starts_with: str = None,
7373
continue_on_error: bool = False,
7474
) -> List[Dict]:
75-
"""Download the specified project files into the destination dir
75+
"""Download the specified project files into the destination dir.
7676
7777
Args:
7878
project_id: id of the project to be downloaded
7979
local_dir: destination directory where the files will be downloaded
80-
subdir: if specified, download only files that are withing that subdirectory, otherwise download all
80+
path_starts_with: if specified, download only files that are within that path starts with, otherwise download all
8181
"""
8282

8383
files = self.list_files(project_id)
@@ -87,13 +87,17 @@ def download_files(
8787
file["status"] = DownloadStatus.PENDING
8888
file["status_reason"] = ""
8989

90+
files_to_download = []
91+
9092
for file in files:
9193
local_file = Path(f'{local_dir}/{file["name"]}')
9294
resp = None
9395

94-
if subdir and not file["name"].startswith(subdir):
96+
if path_starts_with and not file["name"].startswith(path_starts_with):
9597
continue
9698

99+
files_to_download.append(file)
100+
97101
try:
98102
resp = self._request(
99103
"GET",
@@ -125,7 +129,7 @@ def download_files(
125129
f.write(chunk)
126130
files_count += 1
127131

128-
return files
132+
return files_to_download
129133

130134
def _request(
131135
self,

0 commit comments

Comments
 (0)