From: rgrosso Date: Sun, 6 Jul 2014 08:18:19 +0000 (+0200) Subject: Add directory structure (needed if new in cvmfs) X-Git-Url: http://git.uio.no/git/?a=commitdiff_plain;h=42525e7cdf7bd5c06f0b36ca86dd649b8fec1d6c;p=u%2Fmrichter%2FAliRoot.git Add directory structure (needed if new in cvmfs) The tarball contains also the three levels dir structure containing the CDB object, necessary in case part of it is not already in CVMFS. Also, do all in a temporary container directory to avoid clashing with stuff possibly already present in the local directory. --- diff --git a/STEER/CDB/AliCDBGrid.cxx b/STEER/CDB/AliCDBGrid.cxx index c5630169f14..7c4a1adab6f 100644 --- a/STEER/CDB/AliCDBGrid.cxx +++ b/STEER/CDB/AliCDBGrid.cxx @@ -918,22 +918,27 @@ Bool_t AliCDBGrid::PutInCvmfs( TString& filename, TFile* cdbFile ) const AliError(Form("OCDB folder set for an invalid OCDB storage:\n %s", cvmfsDirname.Data())); return kFALSE; } - // now cvmfsDirname is the full dirname in cvmfs (trailing slash included) + // now cvmfsDirname is the full dirname in cvmfs AliDebug(3, Form("Publishing \"%s\" in \"%s\"", basename.Data(), cvmfsDirname.Data())); // Tar the file with the right prefix path. Include the directory structure in the tarball - // to cover the case of a containing directory being new in cvmfs. + // to cover the case of a containing directory being new in cvmfs, plus a container directory + // to avoid clashing with stuff present in the local directory TString firstLevel(threeLevels(0, threeLevels.First('/'))); - gSystem->Exec( Form("rm -r %s", firstLevel.Data()) ); - Int_t result = gSystem->Exec( Form("mkdir -p %s", threeLevels.Data()) ); + TString tempDir("tmpToCvmfsOcdbs"); + gSystem->Exec( Form("rm -r %s > /dev/null 2>&1", tempDir.Data()) ); //to be sure not to publish other stuff in cvmfs + Int_t result = gSystem->Exec( Form("mkdir -p %s/%s", tempDir.Data(), threeLevels.Data()) ); if ( result != 0 ) { - AliError ( Form ( "Could not create the directory \"%s\"", threeLevels.Data() ) ); + AliError ( Form ( "Could not create the directory \"%s/%s\"", tempDir.Data(), threeLevels.Data() ) ); return kFALSE; } - cdbFile->Cp(Form("%s/%s", threeLevels.Data(), basename.Data() )); + cdbFile->Cp(Form("%s/%s/%s", tempDir.Data(), threeLevels.Data(), basename.Data() )); TString tarFileName("cdbObjectToAdd.tar.gz"); + TString cvmfsBaseFolder(cvmfsDirname(0, cvmfsDirname.Last('/'))); + cvmfsBaseFolder = cvmfsBaseFolder(0, cvmfsBaseFolder.Last('/')); + cvmfsBaseFolder = cvmfsBaseFolder(0, cvmfsBaseFolder.Last('/')); // tarCommand should be e.g.: tar --transform 's,^,/cvmfs/alice-ocdb.cern.ch/calibration/data/2010/OCDB/,S' -cvzf objecttoadd.tar.gz basename - result = gSystem->Exec ( Form( "tar --transform 's,^,%s/,S' -cvzf %s %s", cvmfsDirname.Data(), tarFileName.Data(), firstLevel.Data() ) ); + result = gSystem->Exec ( Form( "tar --transform 's,^%s,%s,S' -cvzf %s %s", tempDir.Data(), cvmfsBaseFolder.Data(), tarFileName.Data(), tempDir.Data() ) ); if ( result != 0 ) { AliError ( Form ( "Could not create the tarball for the object \"%s\"", filename.Data() ) ); return kFALSE; @@ -947,7 +952,7 @@ Bool_t AliCDBGrid::PutInCvmfs( TString& filename, TFile* cdbFile ) const } // Remove the local file and the tar-file - gSystem->Exec( Form( "rm -r %s", firstLevel.Data() ) ); + gSystem->Exec( Form( "rm -r %s", tempDir.Data() ) ); gSystem->Exec( Form( "rm %s", tarFileName.Data() ) ); return kTRUE;