Fix #1964 : Unhandled UnpicklingError with corrupt state file
This commit is contained in:
parent
d8560f5c25
commit
2504b2520a
|
@ -608,7 +608,7 @@ class TorrentManager(component.Component):
|
||||||
os.path.join(get_config_dir(), "state", "torrents.state"), "rb")
|
os.path.join(get_config_dir(), "state", "torrents.state"), "rb")
|
||||||
state = cPickle.load(state_file)
|
state = cPickle.load(state_file)
|
||||||
state_file.close()
|
state_file.close()
|
||||||
except (EOFError, IOError, Exception), e:
|
except (EOFError, IOError, Exception, cPickle.UnpicklingError), e:
|
||||||
log.warning("Unable to load state file: %s", e)
|
log.warning("Unable to load state file: %s", e)
|
||||||
|
|
||||||
# Try to use an old state
|
# Try to use an old state
|
||||||
|
@ -683,8 +683,8 @@ class TorrentManager(component.Component):
|
||||||
state_file.flush()
|
state_file.flush()
|
||||||
os.fsync(state_file.fileno())
|
os.fsync(state_file.fileno())
|
||||||
state_file.close()
|
state_file.close()
|
||||||
except IOError:
|
except IOError, e:
|
||||||
log.warning("Unable to save state file.")
|
log.warning("Unable to save state file: %s", e)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# We have to move the 'torrents.state.new' file to 'torrents.state'
|
# We have to move the 'torrents.state.new' file to 'torrents.state'
|
||||||
|
|
|
@ -281,7 +281,7 @@ class FilesTab(Tab):
|
||||||
state_file = open(os.path.join(config_location, filename), "rb")
|
state_file = open(os.path.join(config_location, filename), "rb")
|
||||||
state = cPickle.load(state_file)
|
state = cPickle.load(state_file)
|
||||||
state_file.close()
|
state_file.close()
|
||||||
except (EOFError, IOError, AttributeError), e:
|
except (EOFError, IOError, AttributeError, cPickle.UnpicklingError), e:
|
||||||
log.warning("Unable to load state file: %s", e)
|
log.warning("Unable to load state file: %s", e)
|
||||||
|
|
||||||
if state == None:
|
if state == None:
|
||||||
|
|
|
@ -295,7 +295,7 @@ class ListView:
|
||||||
state_file = open(os.path.join(config_location, filename), "rb")
|
state_file = open(os.path.join(config_location, filename), "rb")
|
||||||
state = cPickle.load(state_file)
|
state = cPickle.load(state_file)
|
||||||
state_file.close()
|
state_file.close()
|
||||||
except (EOFError, IOError), e:
|
except (EOFError, IOError, cPickle.UnpicklingError), e:
|
||||||
log.warning("Unable to load state file: %s", e)
|
log.warning("Unable to load state file: %s", e)
|
||||||
|
|
||||||
# Keep the state in self.state so we can access it as we add new columns
|
# Keep the state in self.state so we can access it as we add new columns
|
||||||
|
|
|
@ -212,7 +212,7 @@ class PeersTab(Tab):
|
||||||
state_file = open(os.path.join(config_location, filename), "rb")
|
state_file = open(os.path.join(config_location, filename), "rb")
|
||||||
state = cPickle.load(state_file)
|
state = cPickle.load(state_file)
|
||||||
state_file.close()
|
state_file.close()
|
||||||
except (EOFError, IOError, AttributeError), e:
|
except (EOFError, IOError, AttributeError, cPickle.UnpicklingError), e:
|
||||||
log.warning("Unable to load state file: %s", e)
|
log.warning("Unable to load state file: %s", e)
|
||||||
|
|
||||||
if state == None:
|
if state == None:
|
||||||
|
|
|
@ -431,7 +431,7 @@ class TorrentDetails(component.Component):
|
||||||
state_file = open(os.path.join(config_location, filename), "rb")
|
state_file = open(os.path.join(config_location, filename), "rb")
|
||||||
state = cPickle.load(state_file)
|
state = cPickle.load(state_file)
|
||||||
state_file.close()
|
state_file.close()
|
||||||
except (EOFError, IOError), e:
|
except (EOFError, IOError, cPickle.UnpicklingError), e:
|
||||||
log.warning("Unable to load state file: %s", e)
|
log.warning("Unable to load state file: %s", e)
|
||||||
|
|
||||||
return state
|
return state
|
||||||
|
|
Loading…
Reference in New Issue