From 9c44e4f875ee8fb4062f4ae127cb40064f2a7b74 Mon Sep 17 00:00:00 2001 From: Octavio Simone <70800577+unbekanntes-pferd@users.noreply.github.com> Date: Mon, 4 Jul 2022 00:00:44 +0200 Subject: [PATCH] catch no file content in bulk download --- dccmd/__init__.py | 2 ++ dccmd/main/download/__init__.py | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/dccmd/__init__.py b/dccmd/__init__.py index 5f7e5e4..17db7ed 100644 --- a/dccmd/__init__.py +++ b/dccmd/__init__.py @@ -759,6 +759,8 @@ async def _download(): await dracoon.logout() sys.exit(1) + + try: await bulk_download(dracoon=dracoon, download_list=download_list, velocity=velocity) except FileConflictError: diff --git a/dccmd/main/download/__init__.py b/dccmd/main/download/__init__.py index 1ff34e4..a2fbb0f 100644 --- a/dccmd/main/download/__init__.py +++ b/dccmd/main/download/__init__.py @@ -1,4 +1,10 @@ +""" +Module implementing bulk download from DRACOON + +""" + import os +import sys import asyncio from pathlib import Path from enum import Enum @@ -12,6 +18,7 @@ from dracoon.nodes.responses import NodeList, Node from ..models import DCTransfer, DCTransferList +from ..util import format_error_message class NodeType(Enum): """ represents DRACOON node types """ @@ -173,6 +180,10 @@ async def create_download_list(dracoon: DRACOON, node_info: Node, target_path: s async def bulk_download(dracoon: DRACOON, download_list: DownloadList, velocity: int = 2): """ download all files within a room (excluded: sub rooms) """ + if len(download_list.file_list.items) <= 0: + typer.echo(format_error_message(f"No files to download in {download_list.node.parentPath}{download_list.node.name}")) + sys.exit(1) + if velocity > 10: velocity = 10 elif velocity < 1: