|
| dcap () |
|
| ~dcap () override=default |
|
std::unique_ptr< writer > | newWriter (const std::string &path, bool mightAppend, size_t sourceSize, size_t readBlockSize, copyRequest::stateType &state, bool noWrite, std::unique_ptr< ioHandle::attrDataType >, std::unique_ptr< acl::list > aclData) override |
|
void | ensureParentDirs (const std::string &path, const std::string &srcPath, inputHandler::base *InputHandler) override |
|
void | remove (const std::string &path, copyRequest::stateType &state) override |
|
bool | renameSimple (const std::string &fromPath, const std::string &toPath) override |
|
base::renameRetvalType | rename (const std::string &fromPath, const std::unique_ptr< const genericStat > &readInitialStat, const std::string &toPath, copyRequest::stateType &state) override |
|
void | doAttributePreservations (const std::string &path, const genericStat &stat) override |
|
Public Member Functions inherited from outputHandler::base |
| ~base () override=default |
|
virtual std::unique_ptr< writer > | newTmpWriter (std::string &path, size_t sourceSize, bool noWrite, std::unique_ptr< ioHandle::attrDataType > attrData, std::unique_ptr< acl::list > aclData) |
|
virtual void | createSymlink (const std::vector< char > &, const std::string &, uid_t, gid_t) |
|
virtual size_t | getMaxNameLength (const std::string &dirPath) |
|
template<class C > |
void | shortenNameToMax (const std::string &path, C &pathBuf, const std::string &suffix) |
|
Public Member Functions inherited from pathHandler |
virtual | ~pathHandler ()=default |
|
virtual std::string | getXattr (const std::string &, const std::string &) |
|
| dcapCommon () |
|
bool | pathExists (const std::string &path) override |
|
std::unique_ptr< const genericStat > | getStat (const std::string &path, bool followLink) override |
|
Definition at line 8 of file outputHandlerDcap.h.
void outputHandler::dcap::doAttributePreservations |
( |
const std::string & |
path, |
|
|
const genericStat & |
stat |
|
) |
| |
|
overridevirtual |
Reimplemented from outputHandler::base.
Definition at line 331 of file outputHandlerDcap.cpp.
334 struct timespec times[2];
335 times[0].tv_nsec = UTIME_OMIT;
337 auto serverStart = path.find(
"://");
338 if (serverStart == std::string::npos) {
339 throw std::runtime_error(path +
" contains no \"://\"");
341 auto realPathStart = path.find(
"/", serverStart + 3);
342 if (realPathStart == std::string::npos) {
343 throw std::runtime_error(path +
" contains no path after server part");
347 "can't set mtime on ", path.c_str() + realPathStart);
353 auto oldmask = umask(0);
354 auto retval = dc_chmod(path.c_str(),
modeBits & ~oldmask);
357 path,
"chmod",
"can't set mode ", dc_errno,
" (", dc_strerror(dc_errno),
") ");
363 if (
gid != -1 ||
uid != -1) {
References errMsg::emit(), genericStat::getMtime(), gid, throwcall::dcap::good0(), throwcall::good0(), genericStat::mode, modeBits, errMsg::notice, genericStat::ownerGid, genericStat::ownerUid, preserve, and uid.
void outputHandler::dcap::ensureParentDirs |
( |
const std::string & |
path, |
|
|
const std::string & |
srcPath, |
|
|
inputHandler::base * |
InputHandler |
|
) |
| |
|
overridevirtual |
Implements outputHandler::base.
Definition at line 36 of file outputHandlerDcap.cpp.
39 std::vector<std::remove_reference<decltype(path)>::type::value_type> disposable_buffer(path.c_str(), path.c_str() + path.size() + 1);
40 std::string dir(dirname(disposable_buffer.data()));
45 statResult = dc_stat(
fixPathUrl(dir).c_str(), &statbuf);
48 if (errno == ENOENT) {
49 auto srcDir = srcPath.substr(0, srcPath.find_last_of(
'/'));
50 while (srcDir.back() ==
'/') {
56 auto aclData = InputHandler->
getAclData(srcDir);
61 auto result = dc_mkdir(
fixPathUrl(dir).c_str(), 0777u);
63 if (result != 0 && errno == EEXIST) {
69 if (
gid != -1 ||
uid != -1) {
73 }
else if (! S_ISDIR(statbuf.st_mode)) {
75 dir,
"ensure parents",
76 "is not a directory (st_mode is ", statbuf.st_mode,
") but should be");
References dcapStat, errMsg::emit(), dcapCommon::fixPathUrl(), inputHandler::base::getAclData(), gid, throwcall::dcap::good0(), errMsg::info, preserve, setAclData(), and uid.
- Bug:
- what if at the end a directory is renamed?
Implements outputHandler::base.
Definition at line 136 of file outputHandlerDcap.cpp.
142 auto statRetVal = dc_stat(
fixPathUrl(fromPath).c_str(), &fromPathStatBuf);
143 if (statRetVal && (errno == ENOENT || errno == ENOTDIR)) {
144 if (readInitialStat && readInitialStat->
isDir()) {
150 }
else if (statRetVal) {
154 genericStat fromPathStat(fromPathStatBuf, std::chrono::seconds(1));
155 if (! readInitialStat || (
156 ! readInitialStat->
isDir() &&
157 (fromPathStat.size != readInitialStat->
size
158 || !fromPathStat.isSameMtimeAs(*readInitialStat)))) {
162 "file (", toPath,
") changed unexpectedly, doing fresh copy");
167 if (retval && (errno == ENOENT || errno == ENOTDIR)) {
168 if (readInitialStat->
isDir()) {
174 "vanished unexpectedly, doing fresh copy");
References outputHandler::base::cantHappen, dcapStat, copyRequest::done, errMsg::emit(), outputHandler::base::fileChanged, outputHandler::base::fileVanished, dcapCommon::fixPathUrl(), throwcall::dcap::good0(), copyRequest::ignore, errMsg::info, genericStat::isDir(), genericStat::isSameMtimeAs(), outputHandler::base::ok, and genericStat::size.