fix
This commit is contained in:
parent
6de9b7b718
commit
cfc1c698df
@ -19,6 +19,17 @@ from Comics._utils.ComicInfo import ComicInfoXml
|
||||
from Comics._utils.downloader import download_images
|
||||
|
||||
class ComicsPipeline():
|
||||
# 500kb
|
||||
def remove_min_file(self, file_path, min_size=500*1024):
|
||||
try:
|
||||
# 使用 os.path.getsize() 获取文件大小(以字节为单位)
|
||||
file_size = os.path.getsize(file_path)
|
||||
if file_size < min_size:
|
||||
os.path.remove(file_path)
|
||||
logging.info(f"清除错误文件: {file_path}")
|
||||
except Exception as e:
|
||||
print(f"获取文件大小失败: {e}")
|
||||
|
||||
'''
|
||||
解析前端传入的item数据
|
||||
将数据进行序列化后传出
|
||||
@ -31,8 +42,10 @@ class ComicsPipeline():
|
||||
if fu.exists(ComicPath(item).PATH_CBZ()): result_item = ItemExporter().export_obj(item)
|
||||
# 不存在漫画CBZ文件
|
||||
else: result_item = JsonExport(file=ComicPath(item).getDirJosnComicChapter()).export_json(ComicLoader(item).load_item(), if_return=True)
|
||||
if not fu.exists(ComicPath(item=item).PATH_CBZ()):
|
||||
cbz_path = ComicPath(item=item).PATH_CBZ()
|
||||
if not fu.exists(cbz_path):
|
||||
return result_item
|
||||
else: self.remove_min_file(cbz_path)
|
||||
return None
|
||||
|
||||
class BaseImagesPipeline(ImagesPipeline):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user