改为用相对路径建立软连接,以便网络访问时可以正确打开视频

This commit is contained in:
lededev
2021-04-19 17:19:21 +08:00
parent d2b5eea042
commit 809067fdaf

View File

@@ -588,7 +588,9 @@ def paste_file_to_folder(filepath, path, number, leak_word, c_word, conf: config
targetpath = path + '/' + number + c_word + houzhui targetpath = path + '/' + number + c_word + houzhui
# 如果soft_link=1 使用软链接 # 如果soft_link=1 使用软链接
if conf.soft_link(): if conf.soft_link():
os.symlink(filepath, targetpath) # 采用相对路径,以便网络访问时能正确打开视频
filerelpath = os.path.relpath(filepath, path)
os.symlink(filerelpath, targetpath)
else: else:
os.rename(filepath, targetpath) os.rename(filepath, targetpath)
# 移走文件后,在原来位置增加一个可追溯的软链接,指向文件新位置 # 移走文件后,在原来位置增加一个可追溯的软链接,指向文件新位置
@@ -596,7 +598,8 @@ def paste_file_to_folder(filepath, path, number, leak_word, c_word, conf: config
# 便于手工找回文件。并将软连接文件名后缀修改,以避免再次被搜刮。 # 便于手工找回文件。并将软连接文件名后缀修改,以避免再次被搜刮。
targetabspath = os.path.abspath(targetpath) targetabspath = os.path.abspath(targetpath)
if targetabspath != os.path.abspath(filepath): if targetabspath != os.path.abspath(filepath):
os.symlink(targetabspath, filepath + '#sym') targetrelpath = os.path.relpath(targetabspath, file_parent_origin_path)
os.symlink(targetrelpath, filepath + '#sym')
sub_res = conf.sub_rule() sub_res = conf.sub_rule()
for subname in sub_res: for subname in sub_res: