Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

下载后目录显示替身文件源文件指向缓存目录这是什么情况 #11

Open
roycms opened this issue Nov 6, 2023 · 3 comments

Comments

@roycms
Copy link

roycms commented Nov 6, 2023

下载后目录显示替身文件源文件指向缓存目录这是什么情况?
怎样解决直接显示实际文件的形式
如下图:

WeChat2fb93f75e34df2b46b981cee94a9ef82

@little51
Copy link
Contributor

little51 commented Nov 6, 2023

model_download.py第31行到33行,将_local_dir_use_symlinks设成False,就生成实际的文件了,但有个问题,就是不支持断点续传了

@roycms
Copy link
Author

roycms commented Nov 7, 2023

已经下载好的在临时文件内,怎样恢复成实际文件?

@roycms
Copy link
Author

roycms commented Nov 7, 2023

import os
import shutil

def replace_aliases_with_originals(directory):
    for root, dirs, files in os.walk(directory):
        for file in files:
            file_path = os.path.join(root, file)
            if os.path.islink(file_path):  # 检查是否为替身文件
                original_path = os.path.realpath(file_path)  # 获取原始文件路径
                if original_path != file_path:  # 检查源文件和目标文件是否相同
                    os.remove(file_path)  # 删除替身文件
                    shutil.copy2(original_path, file_path)  # 将原始文件复制到替身文件的位置
                   # os.remove(original_path)  # 删除原始文件

# 替换指定目录内的替身文件
replace_aliases_with_originals('/Volumes/huggingface/aliendao/dataroot/models/')

我用这个批量搬运了一下,解决了,希望遇到同样问题的可以参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants