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.

{
    checkStackSize(); 
    LOG_TRACE(log, "Migrate directory {} to restorable schema", metadata_path + path);
    bool dir_contains_only_files = true;
    for (auto it = iterateDirectory(path); it->isValid(); it->next())
        if (isDirectory(it->path()))
        {
            dir_contains_only_files = false;
            break;
        }
    
    if (dir_contains_only_files)
    {
        auto result = getExecutor().execute([this, path]
             {
                 for (auto it = iterateDirectory(path); it->isValid(); it->next())
                     migrateFileToRestorableSchema(it->path());
             });
        results.push_back(std::move(result));
    }
    else
    {
        for (auto it = iterateDirectory(path); it->isValid(); it->next())
            if (!isDirectory(it->path()))
            {
                auto source_path = it->path();
                auto result = getExecutor().execute([this, source_path]
                    {