]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliCDBGrid.cxx
Added protections to avoid crashes with Print() when ESDEvent is fetched from the...
[u/mrichter/AliRoot.git] / STEER / AliCDBGrid.cxx
index df3915d6541f569b15a0a9b1399ea2eb57c10c53..f62e17fa53c9b74d9ad8f251e3777d61cb2da6d7 100644 (file)
@@ -319,6 +319,13 @@ Bool_t AliCDBGrid::PrepareId(AliCDBId& id) {
        }
        delete res;
 
+       // GRP entries with explicitly set version escape default incremental versioning
+       if(id.GetPath().Contains("GRP") && id.HasVersion() && lastVersion!=0)
+       {
+               AliDebug(5,Form("Entry %s won't be put in the destination OCDB", id.ToString().Data()));
+               return kFALSE;
+       }
+
        id.SetVersion(lastVersion + 1);
        id.SetSubVersion(0);
 
@@ -341,11 +348,8 @@ Bool_t AliCDBGrid::PrepareId(AliCDBId& id) {
 AliCDBId* AliCDBGrid::GetId(const TObjArray& validFileIds, const AliCDBId& query) {
 // look for the Id that matches query's requests (highest or exact version)
 
-       if(validFileIds.GetEntriesFast() < 1) {
+       if(validFileIds.GetEntriesFast() < 1)
                return NULL;
-       } else if (validFileIds.GetEntriesFast() == 1) {
-               return dynamic_cast<AliCDBId*> (validFileIds.At(0)->Clone());
-       }
 
        TIter iter(&validFileIds);
 
@@ -402,13 +406,13 @@ AliCDBId* AliCDBGrid::GetEntryId(const AliCDBId& queryId) {
        if(selectedId.GetFirstRun() == fRun &&
                        fPathFilter.Comprises(selectedId.GetAliCDBPath()) && fVersion < 0 && !fMetaDataFilter){
                // look into list of valid files previously loaded with AliCDBStorage::FillValidFileIds()
-               AliDebug(2, Form("List of files valid for run %d and for path %s was loaded. Looking there!",
+               AliDebug(2, Form("List of files valid for run %d was loaded. Looking there for fileids valid for path %s!",
                                        selectedId.GetFirstRun(), selectedId.GetPath().Data()));
                dataId = GetId(fValidFileIds, selectedId);
 
        } else {
                // List of files valid for reqested run was not loaded. Looking directly into CDB
-               AliDebug(2, Form("List of files valid for run %d and for path %s was not loaded. Looking directly into CDB!",
+               AliDebug(2, Form("List of files valid for run %d was not loaded. Looking directly into CDB for fileids valid for path %s!",
                                        selectedId.GetFirstRun(), selectedId.GetPath().Data()));
 
                TString filter;
@@ -866,15 +870,23 @@ void AliCDBGrid::QueryValidFiles()
                return;
        }
 
-       AliCDBId validFileId;
-       for(int i=0; i<res->GetEntries(); i++){
-               TString filename = res->GetKey(i, "lfn");
-               if(filename == "") continue;
-               AliDebug(2,Form("Found valid file: %s", filename.Data()));
-               Bool_t result = FilenameToId(filename, validFileId);
-               if(result) {
-                       fValidFileIds.AddLast(validFileId.Clone());
-               }
+       TIter next(res);
+       TMap *map;
+       while ((map = (TMap*)next())) {
+         TObjString *entry;
+         if ((entry = (TObjString *) ((TMap *)map)->GetValue("lfn"))) {
+           TString& filename = entry->String();
+           if(filename.IsNull()) continue;
+           AliDebug(2,Form("Found valid file: %s", filename.Data()));
+           AliCDBId *validFileId = new AliCDBId;
+           Bool_t result = FilenameToId(filename, *validFileId);
+           if(result) {
+             fValidFileIds.AddLast(validFileId);
+           }
+           else {
+             delete validFileId;
+           }
+         }
        }
        delete res;