Skip to content

Commit 8b519c7

Browse files
committed
Skip downloading the S3 metadata if skip_metadata=1 is passed to the API /files/ list endpoint
The metadata (the field `sha256`) for each file version is not needed, since the SDK is using a md5 checksum that is provided anyways.
1 parent 0da05b9 commit 8b519c7

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/qfieldcloud_sdk/cli.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,19 @@ def list_projects(ctx, **opts):
201201

202202
@cli.command()
203203
@click.argument("project_id")
204+
@click.option(
205+
"--skip-metadata/--no-skip-metadata",
206+
"skip_metadata",
207+
default=True,
208+
help="Skip requesting for additional metadata (currently the `sha256` checksum) for each version. Default: --skip-metadata",
209+
)
204210
@click.pass_context
205-
def list_files(ctx, project_id):
211+
def list_files(ctx, project_id, skip_metadata):
206212
"""List QFieldCloud project files."""
207213

208214
log(f'Getting file list for "{project_id}"…')
209215

210-
files = ctx.obj["client"].list_remote_files(project_id)
216+
files = ctx.obj["client"].list_remote_files(project_id, skip_metadata)
211217

212218
if ctx.obj["format_json"]:
213219
print_json(files)

src/qfieldcloud_sdk/sdk.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,15 @@ def list_projects(
138138

139139
return resp.json()
140140

141-
def list_remote_files(self, project_id: str) -> List[Dict[str, Any]]:
142-
resp = self._request("GET", f"files/{project_id}")
141+
def list_remote_files(
142+
self, project_id: str, skip_metadata: bool = True
143+
) -> List[Dict[str, Any]]:
144+
params = {}
145+
146+
if skip_metadata:
147+
params["skip_metadata"] = "1"
148+
149+
resp = self._request("GET", f"files/{project_id}", params=params)
143150
return resp.json()
144151

145152
def create_project(

0 commit comments

Comments
 (0)