void RenameOp::undo() { VLOG(1) << "in undoRename"; if (last == renameList->begin()) { VLOG(1) << "nothing to undo"; return; // nothing to undo } // list has to be processed backwards, otherwise we may rename // directories and directory contents in the wrong order! int undoCount = 0; list<RenameEl>::const_iterator it = last; while (it != renameList->begin()) { --it; VLOG(1) << "undo: renaming " << it->newCName << " -> " << it->oldCName; unix::rename(it->newCName.c_str(), it->oldCName.c_str()); try { dn->renameNode(it->newPName.c_str(), it->oldPName.c_str(), false); } catch (encfs::Error &err) { RLOG(WARNING) << err.what(); // continue on anyway... } ++undoCount; }; RLOG(WARNING) << "Undo rename count: " << undoCount; }
void RenameOp::undo() { rDebug("in undoRename"); if (last == renameList->begin()) { rDebug("nothing to undo"); return; // nothing to undo } // list has to be processed backwards, otherwise we may rename // directories and directory contents in the wrong order! int undoCount = 0; list<RenameEl>::const_iterator it = last; while (it != renameList->begin()) { --it; rDebug("undo: renaming %s -> %s", it->newCName.c_str(), it->oldCName.c_str()); unix::rename(it->newCName.c_str(), it->oldCName.c_str()); try { dn->renameNode(it->newPName.c_str(), it->oldPName.c_str(), false); } catch (rlog::Error &err) { err.log(_RLWarningChannel); } ++undoCount; }; rWarning("Undo rename count: %i", undoCount); }
bool RenameOp::apply() { try { while(last != renameList->end()) { // backing store rename. rDebug("renaming %s -> %s", last->oldCName.c_str(), last->newCName.c_str()); struct stat st; bool preserve_mtime = unix::stat(last->oldCName.c_str(), &st) == 0; // internal node rename.. dn->renameNode( last->oldPName.c_str(), last->newPName.c_str() ); // rename on disk.. if(unix::rename( last->oldCName.c_str(), last->newCName.c_str() ) == -1) { rWarning("Error renaming %s: %s", last->oldCName.c_str(), strerror( errno )); dn->renameNode( last->newPName.c_str(), last->oldPName.c_str(), false ); return false; } if(preserve_mtime) { struct utimbuf ut; ut.actime = st.st_atime; ut.modtime = st.st_mtime; unix::utime(last->newCName.c_str(), &ut); } ++last; } return true; } catch( rlog::Error &err ) { err.log( _RLWarningChannel ); return false; } }
bool RenameOp::apply() { try { while (last != renameList->end()) { // backing store rename. VLOG(1) << "renaming " << last->oldCName << " -> " << last->newCName; struct stat_st st; bool preserve_mtime = unix::stat(last->oldCName.c_str(), &st) == 0; // internal node rename.. dn->renameNode(last->oldPName.c_str(), last->newPName.c_str()); // rename on disk.. if (unix::rename(last->oldCName.c_str(), last->newCName.c_str()) == -1) { RLOG(WARNING) << "Error renaming " << last->oldCName << ": " << strerror(errno); dn->renameNode(last->newPName.c_str(), last->oldPName.c_str(), false); return false; } if (preserve_mtime) { struct utimbuf ut; #ifdef USE_LEGACY_DOKAN ut.actime = st.st_atime; ut.modtime = st.st_mtime; #else ut.actime = st.st_atim.tv_sec; ut.modtime = st.st_mtim.tv_sec; #endif unix::utime(last->newCName.c_str(), &ut); } ++last; } return true; } catch (encfs::Error &err) { RLOG(WARNING) << err.what(); return false; } }