Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling when a file vanishes. #807

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## Unreleased

### Improvements
- Improve parsing OME TIFF channel names ([806](../../pull/806))
- Improve handling when a file vanishes ([807](../../pull/807))

## Version 1.12.0

### Features
Expand Down
14 changes: 12 additions & 2 deletions girder/girder_large_image/models/image_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,23 @@ def _loadTileSource(cls, item, **kwargs):
# First try to use the tilesource we recorded as the preferred one.
# This is faster than trying to find the best source each time.
tileSource = girder_tilesource.AvailableGirderTileSources[sourceName](item, **kwargs)
except TileSourceError:
except TileSourceError as exc:
# We could try any source
# tileSource = girder_tilesource.getGirderTileSource(item, **kwargs)
# but, instead, log that the original source no longer works are
# reraise the exception
logger.warning('The original tile source for item %s is not working' % item['_id'])
raise
try:
file = File().load(item['largeImage']['fileId'], force=True)
localPath = File().getLocalFilePath(file)
open(localPath, 'rb').read(1)
except IOError:
logger.warning(
'Is the original data reachable and readable (it fails via %r)?', localPath)
raise IOError(localPath) from None
except Exception:
pass
raise exc
return tileSource

def getMetadata(self, item, **kwargs):
Expand Down
1 change: 0 additions & 1 deletion girder/girder_large_image/web_client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-underscore": "0.0.10",
"@girder/pug-lint-config": "^3.0.0-rc1",
"pug-lint": "^2.6.0",
"stylint": "^1.5.9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-underscore": "0.0.10",
"@girder/pug-lint-config": "^3.0.0-rc1",
"pug-lint": "^2.6.0",
"stylint": "^1.5.9"
Expand Down
9 changes: 6 additions & 3 deletions large_image/cache_util/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,13 @@ def __call__(cls, *args, **kwargs): # noqa - N805
pass
try:
instance = super().__call__(*args, **kwargs)
except Exception:
except Exception as exc:
with cacheLock:
del cache[key]
raise
try:
del cache[key]
except Exception:
pass
raise exc
instance._classkey = key
with cacheLock:
cache[key] = instance
Expand Down
10 changes: 9 additions & 1 deletion utilities/converter/large_image_converter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,15 @@ def _is_multiframe(path):
:returns: True if multiframe.
"""
_import_pyvips()
image = pyvips.Image.new_from_file(path)
try:
image = pyvips.Image.new_from_file(path)
except Exception:
try:
open(path, 'rb').read(1)
raise
except Exception:
logger.warning('Is the file reachable and readable? (%r)', path)
raise IOError(path) from None
pages = 1
if 'n-pages' in image.get_fields():
pages = image.get_value('n-pages')
Expand Down