Skip to content

Commit

Permalink
fix: Fix Windows OSError when checking if path exists
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Jan 18, 2020
1 parent 7232c97 commit 2a17c75
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/aria2p/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,14 @@ def subcommand_add(api: API, uris: List[str] = None, from_file: str = None) -> i
for uri in uris:
path = Path(uri)

if path.exists():
# On Windows, path.exists() generates an OSError when path is an URI
# See https://github.com/pawamoy/aria2p/issues/41
try:
path_exists = path.exists()
except OSError:
path_exists = False

if path_exists:
if path.suffix == ".torrent":
new_downloads = [api.add_torrent(path)]
elif path.suffix == ".metalink":
Expand Down

0 comments on commit 2a17c75

Please sign in to comment.