Preventing errors where there is no previous wav file.
This commit is contained in:
parent
dff515be46
commit
d1a6654c1d
@ -85,36 +85,37 @@ class AudioWriter(object):
|
||||
file = self.wavefile
|
||||
self.wavefile = self.getWaveFile()
|
||||
|
||||
file.close()
|
||||
tmp_dir = CoreConfig().get_temporary_directory()
|
||||
if file is not None:
|
||||
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:
|
||||
os.link(file.getFileName(), filename)
|
||||
# our master can be deleted now, the profiles will delete their hardlinked copies after processing
|
||||
file.unlink()
|
||||
except OSError:
|
||||
logger.exception("Error while linking job files")
|
||||
continue
|
||||
logger.exception("Error while unlinking job files")
|
||||
|
||||
job = self.chopper.createJob(profile, filename)
|
||||
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()
|
||||
self._scheduleNextSwitch()
|
||||
|
||||
def start(self):
|
||||
self.wavefile = self.getWaveFile()
|
||||
|
Loading…
Reference in New Issue
Block a user