Files
lzwlab_cn/transfer/cleanup.py
T
waiwaylee 5af69d694f feat: 文件快传新增共享剪贴板(跨客户端粘贴、查看与一键复制)
- 后端:新增 /api/clips(列表/新建)、/api/clips/<id>(取全文/删除)、/api/clips/<id>/copy(复制计数),列表仅返回 240 字符预览
- 存储:SQLite 新增 clips 表(含 expires_at 索引),启动自动建表,线上老库无需手工迁移
- 前端:剪贴板卡片支持读取本机剪贴板、来源备注、查看全文、一键复制到本机剪贴板、单条删除与复制次数
- 清理:systemd 定时任务与 /api/cleanup 同时清理过期剪贴板
- 配置:新增 max_clip_length / max_clips / clip_default_expires_hours
- 部署:deploy_transfer.py 新增 --keep-credentials(不重置登录密码与会话密钥)与 SSH 连接重试
- 文档:README / setup.md / CHANGELOG 同步更新
2026-10-11 22:20:54 +08:00

28 lines
841 B
Python

"""手动/定时清理过期文件、过期剪贴板与孤儿缓存文件。"""
import logging
import time
import auth
import storage
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
log = logging.getLogger("lzwlab-cleanup")
def main() -> int:
cfg = auth.load_config()
files_dir = cfg["files_dir"]
db_path = cfg["database_path"]
storage.init_db(db_path)
now = int(time.time())
removed = storage.cleanup_expired(db_path, files_dir, now=now)
orphans = storage.cleanup_orphans(db_path, files_dir, now=now)
clips = storage.cleanup_expired_clips(db_path, now=now)
log.info("清理完成:过期文件 %d 个,孤儿缓存 %d 个,过期剪贴板 %d 条",
removed, orphans, clips)
return 0
if __name__ == "__main__":
raise SystemExit(main())