fix
This commit is contained in:
1 parent
25dfc474ee
commit
3d56218b09
5 files changed
+85
-17
No files matched your search
@@ -67,8 +67,12 @@ class ComicPath:
|
||||
file = os.path.join(settings.CBZ_EXPORT_PATH, PROJECT, name, chapter+".jpg")
|
||||
elif result_type == "down_icon":
|
||||
file = os.path.join(settings.IMAGES_STORE, cls.get_file_path(item=item, result_type="icon"))
|
||||
elif result_type == "down_cache_icon":
|
||||
file = os.path.join(settings.IMAGES_STORE, cls.get_file_path(item=item, result_type="icon_cache"))
|
||||
elif result_type == "icon":
|
||||
file = os.path.join(PROJECT, "icons", name+".jpg")
|
||||
file = os.path.join(PROJECT, "icons", name, name+".jpg")
|
||||
elif result_type == "icon_cache":
|
||||
file = os.path.join(PROJECT, "icons", ".cache", name+".jpg")
|
||||
elif result_type == "cbz":
|
||||
file = os.path.join(settings.CBZ_EXPORT_PATH, PROJECT, name, chapter+".CBZ")
|
||||
elif result_type == "images_dir":
|
||||
|
||||
@@ -22,6 +22,52 @@ class fileUtils:
|
||||
base_dir = os.path.dirname(file)
|
||||
if not os.path.exists(base_dir): os.makedirs(base_dir)
|
||||
return file
|
||||
|
||||
@classmethod
|
||||
def compare_size(cls, dst, file):
|
||||
if os.path.exists(dst) and os.path.exists(file):
|
||||
return os.stat(dst).st_size == os.stat(file).st_size
|
||||
else:
|
||||
return 0
|
||||
|
||||
"""
|
||||
图像编号 image-1.jpg
|
||||
如:存在image.png 返回 image-1.png 反之 image.png
|
||||
"""
|
||||
@classmethod
|
||||
def file_check(cls, file, result="file"):
|
||||
temp_file_name = file
|
||||
count = 1
|
||||
files_size = []
|
||||
name, suffix = temp_file_name.split(".")
|
||||
while count:
|
||||
if os.path.exists(temp_file_name):
|
||||
files_size.append(os.stat(temp_file_name).st_size)
|
||||
temp_file_name = name+"-"+str(count)+"."+suffix
|
||||
count += 1
|
||||
else:
|
||||
if result == "size":
|
||||
return files_size
|
||||
else:
|
||||
return temp_file_name
|
||||
|
||||
@classmethod
|
||||
def file_update(cls, old_file, new_file):
|
||||
is_update = False
|
||||
if os.path.exists(old_file):
|
||||
is_update = os.stat(old_file).st_size not in cls.file_check(new_file, result="size")
|
||||
return is_update
|
||||
|
||||
# 判断是否需要更新封面
|
||||
@classmethod
|
||||
def update_icon(cls, image_path, save_path):
|
||||
# 不存在则更新
|
||||
if cls.file_update(image_path, save_path):
|
||||
save_dir = os.path.dirname(save_path)
|
||||
if not os.path.exists(save_dir): os.makedirs(save_dir)
|
||||
logging.info(f"update icon ... {image_path} ===> {cls.file_check(save_path)}")
|
||||
shutil.copyfile(image_path, cls.file_check(save_path))
|
||||
|
||||
|
||||
class CommonUtils:
|
||||
@classmethod
|
||||
|
||||
Reference in new issue
Block a user