Fix typos and buge

This commit is contained in:
alesapin 2022-06-03 14:35:15 +02:00
parent c7f7e91532
commit 5d30a4ef09
2 changed files with 9 additions and 10 deletions

View File

@ -142,12 +142,13 @@ public:
fs::path p(path);
while (!disk.exists(p))
{
disk.createDirectory(p);
paths_created.push_back(p);
if (!p.has_parent_path())
break;
p = p.parent_path();
}
for (const auto & path_to_create : paths_created | std::views::reverse)
disk.createDirectory(path_to_create);
}
void undo() override
@ -332,24 +333,23 @@ class WriteFileOperation final : public IMetadataOperation
{
private:
std::string path;
std::string temp_path;
IDisk & disk;
public:
WriteFileOperation(const std::string & path_, const std::string & temp_path_, IDisk & disk_)
WriteFileOperation(const std::string & path_, IDisk & disk_)
: path(path_)
, temp_path(temp_path_)
, disk(disk_)
{}
void execute() override
{
disk.moveFile(temp_path, path);
/// Cannot do move here because some code relies on hardlinks.
/// It's impossible to rewrite file and move to hardlink it
/// will became a separate file. Some don't use tmp->move method here.
}
void undo() override
{
disk.removeFileIfExists(path);
disk.removeFileIfExists(temp_path);
}
};
@ -361,9 +361,8 @@ std::unique_ptr<WriteBufferFromFileBase> MetadataStorageFromDisk::writeFile( ///
size_t buf_size,
const WriteSettings & settings)
{
std::string temp_path = getTempFileName();
transaction->addOperation(std::make_unique<WriteFileOperation>(path, temp_path, *disk));
return disk->writeFile(temp_path, buf_size, WriteMode::Rewrite, settings);
transaction->addOperation(std::make_unique<WriteFileOperation>(path, *disk));
return disk->writeFile(path, buf_size, WriteMode::Rewrite, settings);
}

View File

@ -18,7 +18,7 @@ using DataPartsVector = std::vector<DataPartPtr>;
/// This object is responsible for tracking all changes that some transaction is making in MergeTree tables.
/// It collects all changes that queries of current transaction made in data part sets of all MergeTree tables
/// to ether make them visible when transaction commits or undo when transaction rolls back.
/// to either make them visible when transaction commits or undo when transaction rolls back.
class MergeTreeTransaction : public std::enable_shared_from_this<MergeTreeTransaction>, private boost::noncopyable
{
friend class TransactionLog;