diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2014-07-19 18:57:14 +0100 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2014-07-19 20:16:51 +0100 |
commit | c0650f88d15bbe84b4aeaaebb309f4bf1cefe17f (patch) | |
tree | e2e12f4eca4d8362a701654caf4da33429f04e4b | |
parent | 5d5edd2639c5fc97bc95044f1213250b6f9ff215 (diff) | |
download | deluge-c0650f88d15bbe84b4aeaaebb309f4bf1cefe17f.tar.gz deluge-c0650f88d15bbe84b4aeaaebb309f4bf1cefe17f.tar.bz2 deluge-c0650f88d15bbe84b4aeaaebb309f4bf1cefe17f.zip |
Fix to mitigate fastresume corruption
The code in develop is more robust but by writing to a temp file first
then moving it should stop the worst of fastresume corruption issues,
e.g. hard resets.
-rw-r--r-- | deluge/core/torrentmanager.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index c9836aab6..ab702cda3 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -770,6 +770,7 @@ class TorrentManager(component.Component): return path = os.path.join(get_config_dir(), "state", "torrents.fastresume") + path_tmp = path + ".tmp" # First step is to load the existing file and update the dictionary if resume_data is None: @@ -780,11 +781,12 @@ class TorrentManager(component.Component): try: log.debug("Saving fastresume file: %s", path) - fastresume_file = open(path, "wb") + fastresume_file = open(path_tmp, "wb") fastresume_file.write(lt.bencode(resume_data)) fastresume_file.flush() os.fsync(fastresume_file.fileno()) fastresume_file.close() + shutil.move(path_tmp, path) except IOError: log.warning("Error trying to save fastresume file") |