abort tagging if the file has poofed

This commit is contained in:
ed 2021-10-27 00:11:58 +02:00
parent 94dbd70677
commit 6b737bf1d7
3 changed files with 17 additions and 1 deletions

View file

@ -21,6 +21,10 @@ def getsize(p):
return os.path.getsize(fsenc(p)) return os.path.getsize(fsenc(p))
def isfile(p):
return os.path.isfile(fsenc(p))
def isdir(p): def isdir(p):
return os.path.isdir(fsenc(p)) return os.path.isdir(fsenc(p))

View file

@ -413,6 +413,9 @@ class MTag(object):
return r1 return r1
def get_mutagen(self, abspath): def get_mutagen(self, abspath):
if not bos.path.isfile(abspath):
return {}
import mutagen import mutagen
try: try:
@ -458,10 +461,16 @@ class MTag(object):
return self.normalize_tags(ret, md) return self.normalize_tags(ret, md)
def get_ffprobe(self, abspath): def get_ffprobe(self, abspath):
if not bos.path.isfile(abspath):
return {}
ret, md = ffprobe(abspath) ret, md = ffprobe(abspath)
return self.normalize_tags(ret, md) return self.normalize_tags(ret, md)
def get_bin(self, parsers, abspath): def get_bin(self, parsers, abspath):
if not bos.path.isfile(abspath):
return {}
pypath = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) pypath = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
pypath = [str(pypath)] + [str(x) for x in sys.path if x] pypath = [str(pypath)] + [str(x) for x in sys.path if x]
pypath = str(os.pathsep.join(pypath)) pypath = str(os.pathsep.join(pypath))

View file

@ -998,7 +998,10 @@ class Up2k(object):
except Exception as ex: except Exception as ex:
msg = "failed to read tags from {}:\n{}" msg = "failed to read tags from {}:\n{}"
self.log(msg.format(abspath, ex), c=3) self.log(msg.format(abspath, ex), c=3)
return return 0
if not bos.path.isfile(abspath):
return 0
if entags: if entags:
tags = {k: v for k, v in tags.items() if k in entags} tags = {k: v for k, v in tags.items() if k in entags}