Preventing errors where there is no previous wav file.

This commit is contained in:
Marat Fayzullin 2022-11-20 23:33:13 -05:00
parent dff515be46
commit d1a6654c1d

View File

@ -85,36 +85,37 @@ class AudioWriter(object):
file = self.wavefile file = self.wavefile
self.wavefile = self.getWaveFile() self.wavefile = self.getWaveFile()
file.close() if file is not None:
tmp_dir = CoreConfig().get_temporary_directory() file.close()
tmp_dir = CoreConfig().get_temporary_directory()
for profile in self.profiles:
# create hardlinks for the individual profiles
filename = "{tmp_dir}/openwebrx-audiochopper-{pid}-{timestamp}.wav".format(
tmp_dir=tmp_dir,
pid=id(profile),
timestamp=file.getTimestamp().strftime(profile.getFileTimestampFormat()),
)
try:
os.link(file.getFileName(), filename)
except OSError:
logger.exception("Error while linking job files")
continue
job = self.chopper.createJob(profile, filename)
try:
DecoderQueue.getSharedInstance().put(job)
except Full:
logger.warning("decoding queue overflow; dropping one file")
job.unlink()
for profile in self.profiles:
# create hardlinks for the individual profiles
filename = "{tmp_dir}/openwebrx-audiochopper-{pid}-{timestamp}.wav".format(
tmp_dir=tmp_dir,
pid=id(profile),
timestamp=file.getTimestamp().strftime(profile.getFileTimestampFormat()),
)
try: try:
os.link(file.getFileName(), filename) # our master can be deleted now, the profiles will delete their hardlinked copies after processing
file.unlink()
except OSError: except OSError:
logger.exception("Error while linking job files") logger.exception("Error while unlinking job files")
continue
job = self.chopper.createJob(profile, filename) self._scheduleNextSwitch()
try:
DecoderQueue.getSharedInstance().put(job)
except Full:
logger.warning("decoding queue overflow; dropping one file")
job.unlink()
try:
# our master can be deleted now, the profiles will delete their hardlinked copies after processing
file.unlink()
except OSError:
logger.exception("Error while unlinking job files")
self._scheduleNextSwitch()
def start(self): def start(self):
self.wavefile = self.getWaveFile() self.wavefile = self.getWaveFile()