flame: ignore clip file with zero lines

This commit is contained in:
Jakub Jezek 2022-03-28 13:29:40 +02:00
parent 08f80ecf15
commit 34a65cb646
No known key found for this signature in database
GPG key ID: D8548FBF690B100A

View file

@ -708,19 +708,32 @@ class OpenClipSolver:
self.feed_dir = os.path.dirname(feed_path)
self.feed_ext = os.path.splitext(self.feed_basename)[1][1:].lower()
if not os.path.isfile(openclip_file_path):
if not self._is_valid_tmp_file(openclip_file_path):
# openclip does not exist yet and will be created
self.tmp_file = self.out_file = openclip_file_path
self.create_new_clip = True
else:
# update already created clip
# output a temp file
self.out_file = openclip_file_path
self.tmp_file = os.path.join(self.feed_dir, self.tmp_name)
# remove previously generated temp files
# it will be regenerated
self._clear_tmp_file()
self.log.info("Temp File: {}".format(self.tmp_file))
def _is_valid_tmp_file(self, file):
# check if file exists
if os.path.isfile(file):
with open(self.tmp_file) as f:
lines = f.readlines()
if len(lines) < 1:
self._clear_tmp_file()
return False
def make(self):
self._generate_media_info_file()