def clean_oldbackups(self):
'''auto clean old backups'''
backuppath = self.addon.getSetting("backup_path").decode("utf-8")
max_backups = self.addon.getSetting("max_old_backups")
if max_backups:
max_backups = int(max_backups)
all_files = []
for filename in xbmcvfs.listdir(backuppath)[1]:
if ".zip" in filename and "Skinbackup" in filename:
filename = filename.decode("utf-8")
filepath = backuppath + filename
filestat = xbmcvfs.Stat(filepath)
modified = filestat.st_mtime()
del filestat
log_msg(modified)
all_files.append((filepath, modified))
if len(all_files) > max_backups:
from operator import itemgetter
old_files = sorted(all_files, key=itemgetter(1), reverse=True)[max_backups - 1:]
for backupfile in old_files:
delete_file(backupfile[0])
backuprestore.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录