Skip to content

Commit

Permalink
TileDB: make its identify() method more restrictive
Browse files Browse the repository at this point in the history
by not identifying /vsi file systems it doesn't handle

Relates to conda-forge/tiledb-feedstock#228
  • Loading branch information
rouault committed Jan 31, 2024
1 parent b615a92 commit d7c93f0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
12 changes: 10 additions & 2 deletions frmts/tiledb/tiledbcommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,17 @@ int TileDBDataset::Identify(GDALOpenInfo *poOpenInfo)
return TRUE;
}

const bool bIsS3OrGS =
STARTS_WITH_CI(poOpenInfo->pszFilename, "/VSIS3/") ||
STARTS_WITH_CI(poOpenInfo->pszFilename, "/VSIGS/");
// If this is a /vsi virtual file systems, bail out, except if it is S3 or GS.
if (!bIsS3OrGS && STARTS_WITH(poOpenInfo->pszFilename, "/vsi"))
{
return false;
}

if (poOpenInfo->bIsDirectory ||
((STARTS_WITH_CI(poOpenInfo->pszFilename, "/VSIS3/") ||
STARTS_WITH_CI(poOpenInfo->pszFilename, "/VSIGS/")) &&
(bIsS3OrGS &&
!EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "tif")))
{
tiledb::Context ctx;
Expand Down
18 changes: 14 additions & 4 deletions frmts/tiledb/tiledbdrivercore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,20 @@ static int TileDBDriverIdentifySimplified(GDALOpenInfo *poOpenInfo)
return TRUE;
}

if (poOpenInfo->bIsDirectory ||
((STARTS_WITH_CI(poOpenInfo->pszFilename, "/VSIS3/") ||
STARTS_WITH_CI(poOpenInfo->pszFilename, "/VSIGS/")) &&
!EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "tif")))
const bool bIsS3OrGS = STARTS_WITH_CI(poOpenInfo->pszFilename, "/VSIS3/") ||
STARTS_WITH_CI(poOpenInfo->pszFilename, "/VSIGS/");
// If this is a /vsi virtual file systems, bail out, except if it is S3 or GS.
if (!bIsS3OrGS && STARTS_WITH(poOpenInfo->pszFilename, "/vsi"))
{
return false;
}

if (poOpenInfo->bIsDirectory)
{
return GDAL_IDENTIFY_UNKNOWN;
}

if (bIsS3OrGS && !EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "tif"))
{
return GDAL_IDENTIFY_UNKNOWN;
}
Expand Down

0 comments on commit d7c93f0

Please sign in to comment.