[Apt-offline-devel] [SCM] Offline APT Package Manager branch, master, updated. 0.9.5-19-g2b1fdf4

Ritesh Raj Sarraf rrs at researchut.com
Tue Dec 8 10:50:20 UTC 2009


The following commit has been merged in the master branch:
commit c6f705be7007fd32e4f13d7a83e5484c79e57464
Author: Ritesh Raj Sarraf <rrs at researchut.com>
Date:   Thu Dec 3 23:14:54 2009 +0530

    Be careful when updating APT Package Cache data
    
    There are possibilities that we can have APT updates downloaded in
    damaged form. Extra care needs to be taken here.
    We need to unarchive APT's data and ensure that it is clean before
    letting it overwrite the previous data.
    
    This saves us from situation where the new data was downloaded
    corrupted. Having stale APT database is still better than having no APT
    database.
    
    See commit ID: 7fbdf60b6201b582f8fff66920ff6232e383d654 for more details
    about the bzip2 damaged data problem

diff --git a/AptOfflineCoreLib.py b/AptOfflineCoreLib.py
index 642b49f..328ba0f 100644
--- a/AptOfflineCoreLib.py
+++ b/AptOfflineCoreLib.py
@@ -930,10 +930,20 @@ def installer( args ):
             
         def magic_check_and_uncompress( archive_file=None, filename=None):
                 retval = False
-                if AptOfflineMagicLib.file( archive_file ) == "application/x-bzip2":
-                        retval = archive.decompress_the_file( archive_file, apt_update_target_path, filename, "bzip2" )
-                elif AptOfflineMagicLib.file( archive_file ) == "application/x-gzip":
-                        retval = archive.decompress_the_file( archive_file, apt_update_target_path, filename, "gzip" )
+                if AptOfflineMagicLib.file( archive_file ) == "application/x-bzip2" or \
+                AptOfflineMagicLib.file( archive_file ) == "application/x-gzip":
+                        temp_filename = os.path.join(apt_update_target_path, filename + app_name)
+                        filename = os.path.join(apt_update_target_path, filename)
+                        if AptOfflineMagicLib.file( archive_file ) == "application/x-bzip2":
+                                retval = archive.decompress_the_file( archive_file, temp_filename, "bzip2" )
+                        elif AptOfflineMagicLib.file( archive_file ) == "application/x-gzip":
+                                retval = archive.decompress_the_file( archive_file, temp_filename, "gzip" )
+                        else:
+                                retval = False
+                        if retval is True:
+                                os.rename(temp_filename, filename)
+                        else:
+                                os.unlink(temp_filename)
                 elif AptOfflineMagicLib.file( archive_file ) == "application/zip":
                         retval = archive.decompress_the_file( os.path.join( install_file_path, eachfile ), apt_update_target_path, eachfile, "zip" )
                 elif AptOfflineMagicLib.file( archive_file ) == "PGP armored data":

-- 
Offline APT Package Manager



More information about the Apt-offline-devel mailing list