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

TileDB: make Identify() method return false if passed object is not a directory #10798

Merged
merged 1 commit into from
Sep 16, 2024
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
50 changes: 10 additions & 40 deletions frmts/tiledb/tiledbcommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,54 +118,24 @@ CPLErr TileDBDataset::AddFilter(tiledb::Context &ctx,
int TileDBDataset::Identify(GDALOpenInfo *poOpenInfo)

{
if (STARTS_WITH_CI(poOpenInfo->pszFilename, "TILEDB:"))
int nRet = TileDBDriverIdentifySimplified(poOpenInfo);
if (nRet == GDAL_IDENTIFY_UNKNOWN)
{
return TRUE;
}

if (poOpenInfo->IsSingleAllowedDriver("TileDB"))
{
return TRUE;
}

try
{
const char *pszConfig =
CSLFetchNameValue(poOpenInfo->papszOpenOptions, "TILEDB_CONFIG");

if (pszConfig != nullptr)
{
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 ||
(bIsS3OrGS &&
!EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "tif")))
try
{
tiledb::Context ctx;
CPLString osArrayPath =
TileDBDataset::VSI_to_tiledb_uri(poOpenInfo->pszFilename);
const auto eType = tiledb::Object::object(ctx, osArrayPath).type();
if (eType == tiledb::Object::Type::Array ||
eType == tiledb::Object::Type::Group)
return true;
nRet = (eType == tiledb::Object::Type::Array ||
eType == tiledb::Object::Type::Group);
}
catch (...)
{
nRet = FALSE;
}

return FALSE;
}
catch (...)
{
return FALSE;
}
return nRet;
}

/************************************************************************/
Expand Down
19 changes: 7 additions & 12 deletions frmts/tiledb/tiledbdrivercore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/* TileDBDriverIdentifySimplified() */
/************************************************************************/

static int TileDBDriverIdentifySimplified(GDALOpenInfo *poOpenInfo)
int TileDBDriverIdentifySimplified(GDALOpenInfo *poOpenInfo)

{
if (STARTS_WITH_CI(poOpenInfo->pszFilename, "TILEDB:"))
Expand All @@ -56,6 +56,11 @@ static int TileDBDriverIdentifySimplified(GDALOpenInfo *poOpenInfo)
return TRUE;
}

if (!poOpenInfo->bIsDirectory)
{
return false;
}

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.
Expand All @@ -64,17 +69,7 @@ static int TileDBDriverIdentifySimplified(GDALOpenInfo *poOpenInfo)
return false;
}

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

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

return FALSE;
return GDAL_IDENTIFY_UNKNOWN;
}

/************************************************************************/
Expand Down
2 changes: 2 additions & 0 deletions frmts/tiledb/tiledbdrivercore.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ constexpr const char *DRIVER_NAME = "TileDB";
#define TileDBDriverSetCommonMetadata \
PLUGIN_SYMBOL_NAME(TileDBDriverSetCommonMetadata)

int TileDBDriverIdentifySimplified(GDALOpenInfo *poOpenInfo);

void TileDBDriverSetCommonMetadata(GDALDriver *poDriver);

#endif
Loading