Skip to content

Commit 6ebe7a7

Browse files
committed
Revert "Add option to skip downloading locally existing files"
This reverts commit 6e1faf7.
1 parent 4c52064 commit 6ebe7a7

3 files changed

Lines changed: 2 additions & 26 deletions

File tree

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@ Options:
176176
--throw-on-error / --no-throw-on-error
177177
If any project file downloads fails stop
178178
downloading the rest. Default: False
179-
--skip-existing / --no-skip-existing
180-
Skip files if they already exist locally
181-
with same sha256 hash. Default: False
182179
```
183180

184181
#### delete-files

src/bin/qfieldcloud-cli

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,14 @@ def upload_files(ctx, project_id, project_path, filter_glob, throw_on_error):
293293
"--throw-on-error/--no-throw-on-error",
294294
help="If any project file downloads fails stop downloading the rest. Default: False",
295295
)
296-
@click.option(
297-
"--skip-existing/--no-skip-existing",
298-
help="Skip files if they already exist locally with same sha256 hash. Default: False",
299-
)
300296
@click.pass_context
301-
def download_files(ctx, project_id, local_dir, filter_glob, throw_on_error, skip_existing):
297+
def download_files(ctx, project_id, local_dir, filter_glob, throw_on_error):
302298
"""Download QFieldCloud project files."""
303299

304300
log(f'Downloading project "{project_id}" files to {local_dir}…')
305301

306302
files = ctx.obj["client"].download_project(
307-
project_id, local_dir, filter_glob, throw_on_error, skip_existing, show_progress=True,
303+
project_id, local_dir, filter_glob, throw_on_error, show_progress=True
308304
)
309305

310306
if ctx.obj["format_json"]:

src/qfieldcloud_sdk/sdk.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ def download_project(
278278
local_dir: str,
279279
filter_glob: str = None,
280280
throw_on_error: bool = False,
281-
skip_existing: bool = False,
282281
show_progress: bool = False,
283282
) -> List[Dict]:
284283
"""Download the specified project files into the destination dir.
@@ -298,7 +297,6 @@ def download_project(
298297
local_dir,
299298
filter_glob,
300299
throw_on_error,
301-
skip_existing,
302300
show_progress,
303301
)
304302

@@ -479,7 +477,6 @@ def download_files(
479477
local_dir: str,
480478
filter_glob: str = None,
481479
throw_on_error: bool = False,
482-
skip_existing: bool = False,
483480
show_progress: bool = False,
484481
) -> List[Dict]:
485482
"""Download project files.
@@ -492,7 +489,6 @@ def download_files(
492489
filter_glob (str, optional): Download only files matching the glob pattern. If None download all. Defaults to None.
493490
throw_on_error (bool, optional): Throw if download error occurres. Defaults to False.
494491
show_progress (bool, optional): Show progress bar in the console. Defaults to False.
495-
skip_existing (bool, optional): Skip files if they already exist locally with same sha256 hash. Defaults to False.
496492
497493
Raises:
498494
QFieldCloudException: if throw_on_error is True, throw an error if a download request fails.
@@ -508,19 +504,6 @@ def download_files(
508504
for file in files:
509505
if fnmatch.fnmatch(file["name"], filter_glob):
510506
file["status"] = FileTransferStatus.PENDING
511-
512-
local_filename = Path(f'{local_dir}/{file["name"]}')
513-
if skip_existing and local_filename.exists():
514-
515-
sha256_hash = hashlib.sha256()
516-
with open(local_filename, 'rb') as f:
517-
for byte_block in iter(lambda: f.read(4096), b""):
518-
sha256_hash.update(byte_block)
519-
520-
if file['sha256'] == sha256_hash.hexdigest():
521-
logging.info(f'Skip file "{file["name"]}" because it already exists locally')
522-
continue
523-
524507
files_to_download.append(file)
525508

526509
for file in files_to_download:

0 commit comments

Comments
 (0)