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

pfc-V2: implement virtual Cache::Stat() #366

Merged
merged 1 commit into from
May 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 34 additions & 5 deletions src/XrdFileCache/XrdFileCache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,43 @@ Cache::Prepare(const char *url, int oflags, mode_t mode)
}

//______________________________________________________________________________
// virtual method of XrdOucCache2::Stat()
//!
//! @return <0 - Stat failed, value is -errno.
//! =0 - Stat succeeded, sbuff holds stat information.
//! >0 - Stat could not be done, forward operation to next level.
//------------------------------------------------------------------------------

int
Cache::Stat(const char *curl, struct stat &sbuff)
int Cache::Stat(const char *curl, struct stat &sbuff)
{
assert(0 && "Cache::Stat() should not be called.");
return 0;
}
XrdCl::URL url(curl);
std::string name = url.GetPath();

if (m_output_fs->Stat(name.c_str(), &sbuff) == XrdOssOK) {
if ( S_ISDIR(sbuff.st_mode)) {
return 0;
}
else {
bool success = false;
XrdOssDF* infoFile = m_output_fs->newFile(m_configuration.m_username.c_str());
XrdOucEnv myEnv;
name += ".cinfo";
int res = infoFile->Open(name.c_str(), O_RDONLY, 0600, myEnv);
if (res >= 0) {
Info info(0);
if (info.Read(infoFile) > 0) {
sbuff.st_size = info.GetFileSize();
success = true;
}
}
infoFile->Close();
delete infoFile;
return success ? 0 : 1;
}
}

return 1;
}

//______________________________________________________________________________

Expand Down