]> granicus.if.org Git - transmission/commitdiff
delete the old resume file after migrating to the new format
authorCharles Kerr <charles@transmissionbt.com>
Mon, 14 Apr 2008 03:12:24 +0000 (03:12 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Mon, 14 Apr 2008 03:12:24 +0000 (03:12 +0000)
libtransmission/resume.c

index 99b5b97f0b7f6a3e9a62667819d024cda058099e..37d04555bdb65ea34faf2a50edce94952a3b3f76 100644 (file)
@@ -341,10 +341,20 @@ tr_torrentLoadResume( tr_torrent    * tor,
 
     content = tr_loadFile( filename, &contentLen );
     benc_loaded = content && !tr_bencLoad( content, contentLen, &top, NULL );
-    if( !benc_loaded ) {
+    if( !benc_loaded )
+    {
         tr_free( content );
         tr_tordbg( tor, "Couldn't read \"%s\"; trying old resume file format.", filename );
-        return tr_fastResumeLoad( tor, fieldsToLoad, ctor );
+        fieldsLoaded = tr_fastResumeLoad( tor, fieldsToLoad, ctor );
+
+        if( ( fieldsLoaded != 0 ) && ( fieldsToLoad == ~(uint64_t)0 ) )
+        {
+            tr_torrentSaveResume( tor );
+            tr_fastResumeRemove( tor );
+            tr_tordbg( tor, "Migrated resume file to \"%s\"", filename );
+        }
+
+        return fieldsLoaded;
     }
 
     tr_tordbg( tor, "Read resume file \"%s\"", filename );