Commit 1633a022 authored by Michael Davis's avatar Michael Davis
Browse files

[migration] Implements check for file exists in eos-import-files

parent d9e8b88e
......@@ -321,35 +321,41 @@ void EosImportFiles::saveFailedFiles(const std::vector<eos::rpc::FileMdProto> &f
bool EosImportFiles::compareMD(const eos::rpc::FileMdProto &file)
{
return false;
#if 0
auto remote_file = m_eosgrpc->GetMD(eos::rpc::CONTAINER, file.id(), file.path());
auto remote_file = m_eosgrpc->GetMD(eos::rpc::FILE, file.id(), file.path());
// If we send the string "adler" (which is what EOS uses internally), we expect to get back "adler32"
// (because that's what XRootD expects and so EOS maps "adler"->"adler32" when it replies).
if(remote_file.fmd().checksum().type() == "adler32") {
remote_file.mutable_fmd()->mutable_checksum()->set_type("adler");
}
// Check file metadata is the same
if(file.id() != remote_file.cmd().id() ||
file.uid() != remote_file.cmd().uid() ||
file.gid() != remote_file.cmd().gid() ||
file.ctime().sec() != remote_file.cmd().ctime().sec() ||
file.name() != remote_file.cmd().name() ||
(file.path() + '/') != remote_file.cmd().path()) {
if(file.id() != remote_file.fmd().id() ||
file.cont_id() != remote_file.fmd().cont_id() ||
file.uid() != remote_file.fmd().uid() ||
file.gid() != remote_file.fmd().gid() ||
file.size() != remote_file.fmd().size() ||
file.layout_id() != remote_file.fmd().layout_id() ||
file.flags() != remote_file.fmd().flags() ||
file.checksum().type() != remote_file.fmd().checksum().type() ||
file.checksum().value() != remote_file.fmd().checksum().value() ||
file.ctime().sec() != remote_file.fmd().ctime().sec() ||
file.mtime().sec() != remote_file.fmd().mtime().sec() ||
file.name() != remote_file.fmd().name() ||
file.path() != remote_file.fmd().path()) {
return false;
}
if(file.mode() != remote_file.cmd().mode()) {
// EOS gRPC bug prevents us reading back the file mode
std::cerr << "Warning: file " << file.id() << ": injected mode=" << file.mode() <<", read back mode=" << remote_file.cmd().mode() << std::endl;
}
// Check xattrs
for(const auto &xattr : file.xattrs()) {
auto xattr_it = remote_file.cmd().xattrs().find(xattr.first);
if(xattr_it == remote_file.cmd().xattrs().end() || xattr.second != xattr_it->second) {
auto xattr_it = remote_file.fmd().xattrs().find(xattr.first);
if(xattr_it == remote_file.fmd().xattrs().end() || xattr.second != xattr_it->second) {
std::cerr << "file " << file.id() << ": xattrs do not match" << std::endl;
return false;
}
}
return true;
#endif
}
......@@ -473,8 +479,11 @@ std::string EosImportFiles::convertChecksum(uint32_t adler32)
uint32_t EosImportFiles::convertChecksum(const std::string &bytes)
{
uint32_t adler32;
for(int i = 0; i < 4; ++i, adler32 <<= 8) { adler32 += bytes[i]; }
uint32_t adler32 = 0;
for(int i = 0; i < 4; ++i) {
adler32 <<= 8;
adler32 += static_cast<unsigned char>(bytes[i]);
}
return adler32;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment