(本文针对升级之前没有备份的朋友,血泪教训)
升级之后所有的种子和 resume 文件名都会变成 40位 hash 值,如果直接把 transmission-daemon 替换回 2.94,那么就会对所有种子重新校验!
更惨的是重启 tr 之后,这些种子还会重新校验!
写了个 Python 脚本,放到
/volumeX/@appstore/transmission/var
复制代码
下面执行(这个路径自己找一下,需要修改,每个人安装路径不一样,可以用 ps aux | grep transmission 来查找),
(可能)需要 root 权限,执行之前强烈建议对 var 文件夹做备份!
#!/usr/bin/env python
# encoding: utf-8
import os,re
regex = r"(\w{16})\.resume"
regex2 = r"(\w{40})\.resume"
regex3 = r"(\w{40})\.torrent"
resumes = os.listdir("resume/")
torrents = os.listdir("torrents/")
for resume in resumes:
if len(resume) == 47 and len(re.findall(regex2, resume, re.MULTILINE)) > 0:
os.remove("resume/" + resume)
print("remove: ", resume)
continue
hash16 = re.findall(regex, resume, re.MULTILINE)[0]
print(len(resume), resume, hash16)
ts = [x for x in torrents if x.find(hash16) > -1]
if len(ts) > 0:
t = ts[0]
if len(re.findall(regex3, t, re.MULTILINE)) > 0:
t_new = resume.replace("resume", "torrent")
os.rename("torrents/" + t, "torrents/" + t_new)
print("find: ", len(t), t, t_new)