Skip to content

Commit

Permalink
Merge pull request #459 from girder/multiple-dot-filenames
Browse files Browse the repository at this point in the history
Fix a bug handling filenames with multiple periods in a row.
  • Loading branch information
manthey authored Jun 15, 2020
2 parents 712ce6d + ef0a95d commit 1d8a1b3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion girder/girder_large_image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def checkForLargeImageFiles(event):
mimeType = file.get('mimeType')
if mimeType in girder_tilesource.KnownMimeTypes:
possible = True
exts = [ext.split()[0] for ext in file.get('exts')]
exts = [ext.split()[0] for ext in file.get('exts') if ext]
if set(exts[-2:]).intersection(girder_tilesource.KnownExtensions):
possible = True
if not file.get('itemId') or not possible:
Expand Down
2 changes: 1 addition & 1 deletion girder/girder_large_image/girder_tilesource.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def getGirderTileSourceName(item, file=None, *args, **kwargs):
loadGirderTileSources()
if not file:
file = File().load(item['largeImage']['fileId'], force=True)
extensions = [entry.lower().split()[0] for entry in file['exts']]
extensions = [entry.lower().split()[0] for entry in file['exts'] if entry]
sourceList = []
for sourceName in AvailableGirderTileSources:
if not getattr(AvailableGirderTileSources[sourceName], 'girderSource', False):
Expand Down
30 changes: 30 additions & 0 deletions girder/test_girder/test_tiles_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,3 +1129,33 @@ def testTilesInternalMetadata(server, admin, fsAssetstore):
itemId = str(file['itemId'])
resp = server.request(path='/item/%s/tiles/internal_metadata' % itemId)
assert resp.json['tilesource'] == 'tiff'


@pytest.mark.usefixtures('unbindLargeImage') # noqa
@pytest.mark.usefixtures('girderWorker') # noqa
@pytest.mark.plugin('large_image')
def testTilesFromMultipleDotName(boundServer, admin, fsAssetstore, girderWorker): # noqa
# Unicode file names shouldn't cause problems when generating tiles.
file = utilities.uploadTestFile('yb10kx5k.png', admin, fsAssetstore)
# Our normal testing method doesn't pass through the unicode name
# properly, so just change it after upload.
file = File().load(file['_id'], force=True)
file['name'] = 'A name with...dots.png'
file = File().save(file)
fileId = str(file['_id'])

itemId = str(file['itemId'])
item = Item().load(itemId, force=True)
item['name'] = 'A name with...dots.png'
item = Item().save(item)

tileMetadata = _postTileViaHttp(boundServer, admin, itemId, fileId)
assert tileMetadata['tileWidth'] == 256
assert tileMetadata['tileHeight'] == 256
assert tileMetadata['sizeX'] == 10000
assert tileMetadata['sizeY'] == 5000
assert tileMetadata['levels'] == 7
assert tileMetadata['magnification'] is None
assert tileMetadata['mm_x'] is None
assert tileMetadata['mm_y'] is None
_testTilesZXY(boundServer, admin, itemId, tileMetadata)

0 comments on commit 1d8a1b3

Please sign in to comment.