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.

if (restore_information.detached)
    {
        Strings not_finished_prefixes{"tmp_", "delete_tmp_", "attaching_", "deleting_"};
        for (const auto & path : renames)
        {
            
            if (path.find("/detached/") != std::string::npos)
                continue;
            
            fs::path directory_path(path);
            auto directory_name = directory_path.parent_path().filename().string();
            auto predicate = [&directory_name](String & prefix) { return directory_name.starts_with(prefix); };
            if (std::any_of(not_finished_prefixes.begin(), not_finished_prefixes.end(), predicate))
                continue;
            auto detached_path = pathToDetached(path);
            LOG_TRACE(log, "Move directory to 'detached' {} -> {}", path, detached_path);
            fs::path from_path = fs::path(metadata_path) / path;
            fs::path to_path = fs::path(metadata_path) / detached_path;
            if (path.ends_with('/'))
                to_path /= from_path.parent_path().filename();
            else
                to_path /= from_path.filename();
            fs::create_directories(to_path);
            fs::copy(from_path, to_path, fs::copy_options::recursive | fs::copy_options::overwrite_existing);
            fs::remove_all(from_path);
        }
    }
    LOG_INFO(log, "File operations restored for disk {}", name);
}
std::tuple<UInt64, String> DiskS3::extractRevisionAndOperationFromKey(const String & key)