diff --git a/thorlcr/thorutil/thormisc.cpp b/thorlcr/thorutil/thormisc.cpp index 63d0431f7e0..12926c92956 100644 --- a/thorlcr/thorutil/thormisc.cpp +++ b/thorlcr/thorutil/thormisc.cpp @@ -1709,31 +1709,30 @@ void saveWuidToFile(const char *wuid) bool hasTLK(IDistributedFile &file, CActivityBase *activity) { unsigned np = file.numParts(); + if (np<=1) // NB: a better test would be to only continue if this is a width that is +1 of group it's based on, but not worth checking + return false; IDistributedFilePart &part = file.queryPart(np-1); bool keyHasTlk = strisame("topLevelKey", part.queryAttributes().queryProp("@kind")); if (!keyHasTlk) { // See HPCC-32845 - check if TLK flag is missing from TLK part // It is very likely the last part should be a TLK. Even a local key (>1 parts) has a TLK by default (see buildLocalTlks) - if (np>1) + RemoteFilename rfn; + part.getFilename(rfn); + StringBuffer filename; + rfn.getPath(filename); + Owned index = createKeyIndex(filename, 0, false, 0); + dbgassertex(index); + if (index->isTopLevelKey()) { - RemoteFilename rfn; - part.getFilename(rfn); - StringBuffer filename; - rfn.getPath(filename); - Owned index = createKeyIndex(filename, 0, false, 0); - dbgassertex(index); - if (index->isTopLevelKey()) + if (activity) { - if (activity) - { - Owned e = MakeActivityException(activity, 0, "TLK file part of file %s is missing kind=\"topLevelKey\" flag. The meta data should be fixed!", file.queryLogicalName()); - reportExceptionToWorkunitCheckIgnore(activity->queryJob().queryWorkUnit(), e, SeverityWarning); - StringBuffer errMsg; - UWARNLOG("%s", e->errorMessage(errMsg).str()); - } - keyHasTlk = true; + Owned e = MakeActivityException(activity, 0, "TLK file part of file %s is missing kind=\"topLevelKey\" flag. The meta data should be fixed!", file.queryLogicalName()); + reportExceptionToWorkunitCheckIgnore(activity->queryJob().queryWorkUnit(), e, SeverityWarning); + StringBuffer errMsg; + UWARNLOG("%s", e->errorMessage(errMsg).str()); } + keyHasTlk = true; } } return keyHasTlk;