Skip to content

Commit

Permalink
Merge pull request #34 from espnet/fallback
Browse files Browse the repository at this point in the history
fallback when not having write permission
  • Loading branch information
kamo-naoyuki authored Jun 10, 2021
2 parents 89df634 + eddcaa4 commit 7fc971c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions espnet_model_zoo/downloader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
from distutils.util import strtobool
import hashlib
import os
from pathlib import Path
import re
import shutil
Expand Down Expand Up @@ -90,7 +91,11 @@ class ModelDownloader:

def __init__(self, cachedir: Union[Path, str] = None):
if cachedir is None:
# The default path is the directory of this module
cachedir = Path(__file__).parent
# If not having write permission, fallback to homedir
if not os.access(cachedir, os.W_OK):
cachedir = Path.home() / ".cache" / "espnet_model_zoo"
else:
cachedir = Path(cachedir).expanduser().absolute()
cachedir.mkdir(parents=True, exist_ok=True)
Expand Down

0 comments on commit 7fc971c

Please sign in to comment.