Commit 910a94f8 authored by Daniele Kruse's avatar Daniele Kruse
Browse files

File size now gets propagated from RemoteNS to CastorNS when archiving

parent b747dda2
......@@ -158,9 +158,10 @@ std::string cta::CastorNameServer::getDirStorageClass(const SecurityIdentity &re
// createFile
//------------------------------------------------------------------------------
void cta::CastorNameServer::createFile(const SecurityIdentity &requester,
const std::string &path, const mode_t mode) {
const std::string &path, const mode_t mode, const uint64_t size) {
Utils::assertAbsolutePathSyntax(path);
exception::Serrnum::throwOnMinusOne(Cns_creat(path.c_str(), mode), __FUNCTION__);
exception::Serrnum::throwOnMinusOne(Cns_setfsize(path.c_str(), NULL, size, 0, 0), __FUNCTION__);
setOwner(requester, path, requester.getUser());
}
......
......@@ -51,7 +51,7 @@ public:
std::string getDirStorageClass(const SecurityIdentity &requester, const std::string &path) const;
void createFile(const SecurityIdentity &requester, const std::string &path, const mode_t mode);
void createFile(const SecurityIdentity &requester, const std::string &path, const mode_t mode, const uint64_t size);
void setOwner(const SecurityIdentity &requester, const std::string &path, const UserIdentity &owner);
......
......@@ -238,7 +238,8 @@ std::string cta::MockNameServer::getDirStorageClass(
void cta::MockNameServer::createFile(
const SecurityIdentity &requester,
const std::string &path,
const mode_t mode) {
const mode_t mode,
const uint64_t size) {
Utils::assertAbsolutePathSyntax(path);
const std::string dir = Utils::getEnclosingPath(path);
assertFsDirExists(m_fsDir + dir);
......
......@@ -60,7 +60,7 @@ public:
std::string getDirStorageClass(const SecurityIdentity &requester, const std::string &path) const;
void createFile(const SecurityIdentity &requester, const std::string &path, const mode_t mode);
void createFile(const SecurityIdentity &requester, const std::string &path, const mode_t mode, const uint64_t size);
void setOwner(const SecurityIdentity &requester, const std::string &path, const UserIdentity &owner);
......
......@@ -100,8 +100,8 @@ TEST_F(cta_MockNameServerTest, createFile_functionality) {
ArchiveDirIterator itor;
ASSERT_NO_THROW(ns->setOwner(s_adminOnAdminHost, "/", s_user));
ASSERT_NO_THROW(ns->createFile(s_userOnUserHost, "/file1", 0666));
ASSERT_THROW(ns->createFile(s_userOnUserHost, "/file1", 0666), std::exception);
ASSERT_NO_THROW(ns->createFile(s_userOnUserHost, "/file1", 0666, 0));
ASSERT_THROW(ns->createFile(s_userOnUserHost, "/file1", 0666, 0), std::exception);
ASSERT_NO_THROW(itor = ns->getDirContents(s_userOnUserHost, "/"));
ASSERT_EQ(itor.hasMore(), true);
ASSERT_EQ(itor.next().name, "file1");
......@@ -121,7 +121,7 @@ TEST_F(cta_MockNameServerTest, rmdir_functionality) {
ASSERT_NO_THROW(ns->deleteDir(s_userOnUserHost, "/dir1"));
ASSERT_THROW(ns->deleteDir(s_userOnUserHost, "/dir1"), std::exception);
ASSERT_NO_THROW(ns->createDir(s_userOnUserHost, "/dir2", 0777));
ASSERT_NO_THROW(ns->createFile(s_userOnUserHost, "/dir2/file1", 0666));
ASSERT_NO_THROW(ns->createFile(s_userOnUserHost, "/dir2/file1", 0666, 0));
ASSERT_THROW(ns->deleteDir(s_userOnUserHost, "/dir2"), std::exception);
ASSERT_NO_THROW(ns->deleteFile(s_userOnUserHost, "/dir2/file1"));
ASSERT_NO_THROW(ns->deleteDir(s_userOnUserHost, "/dir2"));
......
......@@ -213,7 +213,8 @@ public:
virtual void createFile(
const SecurityIdentity &requester,
const std::string &path,
const mode_t mode) = 0;
const mode_t mode,
const uint64_t size) = 0;
/**
* Sets the owner of the specified file or directory entry.
......
......@@ -653,7 +653,7 @@ void cta::Scheduler::queueArchiveToFileRequest(
std::unique_ptr<SchedulerDatabase::ArchiveToFileRequestCreation>
requestCreation (m_db.queue(rqst));
try {
m_ns.createFile(requester, rqst.archiveFile, 0666);
m_ns.createFile(requester, rqst.archiveFile, remoteFile.status.mode, remoteFile.status.size);
} catch(std::exception &nsEx) {
// Try our best to cleanup the scheduler database. The garbage collection
// logic will try again if we fail.
......
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