Fixing stored file name computation.
This commit is contained in:
parent
81d975f0d8
commit
355cc0dfbe
11
owrx/fax.py
11
owrx/fax.py
|
|
@ -32,16 +32,17 @@ class FaxParser(ThreadModule):
|
|||
def closeFile(self):
|
||||
if self.file is not None:
|
||||
try:
|
||||
logger.debug("Closing bitmap file '%s'." % self.file.name)
|
||||
filePath = self.file.name
|
||||
logger.debug("Closing bitmap file '%s'." % filePath)
|
||||
self.file.close()
|
||||
self.file = None
|
||||
if self.height==0 or self.line<self.height:
|
||||
logger.debug("Deleting short bitmap file '%s'." % self.file.name)
|
||||
os.unlink(self.file.name)
|
||||
logger.debug("Deleting short bitmap file '%s'." % filePath)
|
||||
os.unlink(filePath)
|
||||
else:
|
||||
# Convert file from BMP to PNG
|
||||
logger.debug("Converting '%s' to PNG..." % self.file.name)
|
||||
Storage.convertImage(self.file.name)
|
||||
logger.debug("Converting '%s' to PNG..." % filePath)
|
||||
Storage.convertImage(filePath)
|
||||
# Delete excessive files from storage
|
||||
logger.debug("Performing storage cleanup...")
|
||||
Storage.getSharedInstance().cleanStoredFiles()
|
||||
|
|
|
|||
11
owrx/sstv.py
11
owrx/sstv.py
|
|
@ -75,16 +75,17 @@ class SstvParser(ThreadModule):
|
|||
def closeFile(self):
|
||||
if self.file is not None:
|
||||
try:
|
||||
logger.debug("Closing bitmap file '%s'." % self.file.name)
|
||||
filePath = self.file.name
|
||||
logger.debug("Closing bitmap file '%s'." % filePath)
|
||||
self.file.close()
|
||||
self.file = None
|
||||
if self.height==0 or self.line<self.height:
|
||||
logger.debug("Deleting short bitmap file '%s'." % self.file.name)
|
||||
os.unlink(self.file.name)
|
||||
logger.debug("Deleting short bitmap file '%s'." % filePath)
|
||||
os.unlink(filePath)
|
||||
else:
|
||||
# Convert file from BMP to PNG
|
||||
logger.debug("Converting '%s' to PNG..." % self.file.name)
|
||||
Storage.convertImage(self.file.name)
|
||||
logger.debug("Converting '%s' to PNG..." % filePath)
|
||||
Storage.convertImage(filePath)
|
||||
# Delete excessive files from storage
|
||||
logger.debug("Performing storage cleanup...")
|
||||
Storage.getSharedInstance().cleanStoredFiles()
|
||||
|
|
|
|||
|
|
@ -35,10 +35,10 @@ class Storage(object):
|
|||
with self.lock:
|
||||
if not os.path.exists(filePath):
|
||||
return open(filePath, "wb", buffering = buffering)
|
||||
elif filePath.contains("."):
|
||||
elif "." in filePath:
|
||||
filePathX = "-{0}.".join(filePath.rsplit(".", 1))
|
||||
for i in range(99):
|
||||
filePath1 = filePathX.format(i)
|
||||
filePath1 = filePathX.format(i + 1)
|
||||
if not os.path.exists(filePath1):
|
||||
return open(filePath1, "wb", buffering = buffering)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue