do not show error message when file does not exist, fixed return

This commit is contained in:
Andreas Preikschat 2011-03-24 22:13:51 +01:00
parent 9376d7e965
commit a9cd8db787

View File

@ -483,6 +483,7 @@ class ServiceManager(QtGui.QWidget):
allow_zip_64 = (total_size > 2147483648 + len(service_content)) allow_zip_64 = (total_size > 2147483648 + len(service_content))
log.debug(u'ServiceManager.saveFile - allowZip64 is %s' % allow_zip_64) log.debug(u'ServiceManager.saveFile - allowZip64 is %s' % allow_zip_64)
zip = None zip = None
success = True
try: try:
zip = zipfile.ZipFile(path_file_name, 'w', zipfile.ZIP_STORED, zip = zipfile.ZipFile(path_file_name, 'w', zipfile.ZIP_STORED,
allow_zip_64) allow_zip_64)
@ -494,13 +495,16 @@ class ServiceManager(QtGui.QWidget):
zip.write(path_from, path_from.encode(u'utf-8')) zip.write(path_from, path_from.encode(u'utf-8'))
except IOError: except IOError:
log.exception(u'Failed to save service to disk') log.exception(u'Failed to save service to disk')
return False success = False
finally: finally:
if zip: if zip:
zip.close() zip.close()
if success:
self.mainwindow.addRecentFile(path_file_name) self.mainwindow.addRecentFile(path_file_name)
self.setModified(False) self.setModified(False)
return True else:
delete_file(path_file_name)
return success
def saveFileAs(self): def saveFileAs(self):
""" """
@ -525,8 +529,9 @@ class ServiceManager(QtGui.QWidget):
def loadFile(self, fileName): def loadFile(self, fileName):
if not fileName: if not fileName:
return False return False
else:
fileName = unicode(fileName) fileName = unicode(fileName)
if not os.path.exists(fileName):
return False
zip = None zip = None
fileTo = None fileTo = None
try: try: