Skip to content

Commit 789ea06

Browse files
committed
gather if jobs exist
1 parent 9a0bcb8 commit 789ea06

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

cterasdk/cli/dav.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ..core.enum import FileAccessMode
77
from ..lib.storage import asynfs, commonfs
88
from ..objects.asynchronous.invitation import AsyncInvitation
9-
from ..exceptions.io.core import ListDirectoryError, GetMetadataError
9+
from ..exceptions.io.core import ListDirectoryError, GetMetadataError, ExternalShareError
1010

1111

1212
async def handle_ls(args):
@@ -83,9 +83,9 @@ async def download(invitation, resource, objects=None, archive=False, destinatio
8383
jobs.append(download(invitation, r, destination=target))
8484
except (GetMetadataError, ListDirectoryError):
8585
print(f"error: failed to obtain properties or list a directory: '{args.src}'", file=sys.stderr)
86-
sys.exit(1)
8786

88-
await asyncio.gather(*jobs)
87+
if jobs:
88+
await asyncio.gather(*jobs)
8989

9090
except PermissionError:
9191
print(f"error: permission denied: Cannot create files and folders at '{target}'.", file=sys.stderr)
@@ -123,9 +123,10 @@ async def handle_upload(args):
123123
for p in args.files:
124124
jobs.append(invitation.files.upload_file(p, destination))
125125

126-
await asyncio.gather(*jobs)
126+
if jobs:
127+
await asyncio.gather(*jobs)
127128

128-
except GetMetadataError:
129+
except (GetMetadataError, ExternalShareError):
129130
print(f"error: failed to obtain properties for directory: '{args.dest}'", file=sys.stderr)
130131
sys.exit(1)
131132

0 commit comments

Comments
 (0)