Skip to content

Commit

Permalink
FIX: catch and log explicit exceptions getting disk metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmilloy committed Aug 21, 2020
1 parent 9b25c42 commit 81351a4
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions podpac/core/cache/disk_cache_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
import shutil
import json
import fnmatch
import logging

import podpac
from podpac.core.settings import settings
from podpac.core.cache.utils import CacheException, CacheWildCard
from podpac.core.cache.file_cache_store import FileCacheStore


logger = logging.getLogger(__name__)


class DiskCacheStore(FileCacheStore):
"""Cache that uses a folder on a local disk file system."""

Expand Down Expand Up @@ -100,7 +104,13 @@ def _get_metadata(self, path, key):
try:
with open(metadata_path, "r") as f:
metadata = json.load(f)
except:
except IOError:
# missing, permissions
logger.exception("Error reading metadata file: '%s'" % metadata_path)
return None
except ValueError:
# invalid json
logger.exception("Error reading metadata file: '%s'" % metadata_path)
return None

return metadata.get(key)
Expand All @@ -112,7 +122,13 @@ def _set_metadata(self, path, key, value):
try:
with open(metadata_path, "r") as f:
metadata = json.load(f)
except:
except IOError:
# missing, permissions
logger.exception("Error reading metadata file: '%s'" % metadata_path)
metadata = {}
except ValueError:
# invalid json
logger.exception("Error reading metadata file: '%s'" % metadata_path)
metadata = {}

# write
Expand Down

0 comments on commit 81351a4

Please sign in to comment.