In class IDiskRemote, all metadata file system operations use os file system api directly.
There is little extendiability if we want store the metadata of HDFS or S3 into distributed file system.
So I suggest change this way by using DiskPtr and will propose a pull request.

In addition, metadata of HDFS or S3 only store local FS which is not sharable.

{
    
    auto metadata = createMeta(path);
    metadata.save();
}
size_t IDiskRemote::getFileSize(const String & path) const
{
    auto metadata = readMeta(path);
    return metadata.total_size;
}
void IDiskRemote::moveFile(const String & from_path, const String & to_path)
{
    if (exists(to_path))
        throw Exception("File already exists: " + to_path, ErrorCodes::FILE_ALREADY_EXISTS);
    fs::rename(fs::path(metadata_path) / from_path, fs::path(metadata_path) / to_path);
}
void IDiskRemote::replaceFile(const String & from_path, const String & to_path)
{
    if (exists(to_path))
    {
        const String tmp_path = to_path + ".old";
        moveFile(to_path, tmp_path);
        moveFile(from_path, to_path);
        removeFile(tmp_path);
    }
    else
        moveFile(from_path, to_path);
}
void IDiskRemote::removeSharedFile(const String & path, bool keep_in_remote_fs)