Skip to content

Commit

Permalink
catch no file content in bulk download
Browse files Browse the repository at this point in the history
  • Loading branch information
unbekanntes-pferd committed Jul 3, 2022
1 parent 97b9b5a commit 9c44e4f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dccmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions dccmd/main/download/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
"""
Module implementing bulk download from DRACOON
"""

import os
import sys
import asyncio
from pathlib import Path
from enum import Enum
Expand All @@ -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 """
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9c44e4f

Please sign in to comment.