fix
This commit is contained in:
1 parent
29db14b827
commit
5cc8b385cc
2 files changed
+15
-5
No files matched your search
+14
-5
@@ -206,26 +206,35 @@ class fileUtils:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def notExists(cls,path):
|
def notExists(cls,path):
|
||||||
return not cls.exists(path)
|
return not cls.exists(path)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def size(cls,file_path,unit=None):
|
||||||
|
size = 0
|
||||||
|
if cls.exists(file_path): size = os.path.getsize(file_path)
|
||||||
|
if unit == "kb" or unit == "KB":
|
||||||
|
return str(size/1000)+"KB"
|
||||||
|
if unit == None:
|
||||||
|
return size
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def ver_file(cls,file_path,type):
|
def ver_file(cls,file_path,type):
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
file_size = os.path.getsize(file_path)
|
file_size_unit = cls.size(file_path,unit="kb")
|
||||||
if type == "image" and int(file_size) > 100:
|
if type == "image" and int(cls.size(file_path)) > 100:
|
||||||
#验证是否是图像
|
#验证是否是图像
|
||||||
try:
|
try:
|
||||||
img = Image.open(file_path)
|
img = Image.open(file_path)
|
||||||
img.verify()
|
img.verify()
|
||||||
img.close()
|
img.close()
|
||||||
print(f"{file_path} 类型为type:{type} size: {file_size}")
|
print(f"{file_path} 类型为type:{type} size: {file_size_unit}")
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
print(f"{file_path}已损坏 type:{type} size: {file_size},删除重试中")
|
print(f"{file_path}已损坏 type:{type} size: {file_size_unit},删除重试中")
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print(f"文件小于100b删除中,{file_path} size: {file_size}")
|
print(f"文件小于100b删除中,{file_path} size: {file_size_unit}")
|
||||||
try:
|
try:
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ def download_comic_icon(is_new=comicInfo.IS_NEW_ICON):
|
|||||||
if not os.path.exists(base_dir): os.makedirs(base_dir)
|
if not os.path.exists(base_dir): os.makedirs(base_dir)
|
||||||
shutil.copy(path_comic_icon,os.path.join(base_dir,save_name+icon_prefix))
|
shutil.copy(path_comic_icon,os.path.join(base_dir,save_name+icon_prefix))
|
||||||
else:
|
else:
|
||||||
|
if fu.notExists(comicInfo.getDirCBZComic()): os.makedirs(comicInfo.getDirCBZComic())
|
||||||
shutil.copy(path_comic_icon,save_path)
|
shutil.copy(path_comic_icon,save_path)
|
||||||
print(f"{path_comic_icon} 已复制至: {save_path}")
|
print(f"{path_comic_icon} 已复制至: {save_path}")
|
||||||
#保存icon信息
|
#保存icon信息
|
||||||
|
|||||||
Reference in new issue
Block a user