]> git.saurik.com Git - apt.git/commitdiff
Changed CD ident rountine to not use inodes
authorArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:53:57 +0000 (16:53 +0000)
committerArch Librarian <arch@canonical.com>
Mon, 20 Sep 2004 16:53:57 +0000 (16:53 +0000)
Author: jgg
Date: 1999-06-05 03:54:29 GMT
Changed CD ident rountine to not use inodes

apt-pkg/contrib/cdromutl.cc
apt-pkg/contrib/cdromutl.h
methods/cdrom.cc

index d0d810c5d05e5b3408ba0352aaaac1ea8d549b9d..99eb540ec2a6001bc3039926825e08873e39103f 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: cdromutl.cc,v 1.5 1999/04/20 05:11:17 jgg Exp $
+// $Id: cdromutl.cc,v 1.6 1999/06/05 03:54:29 jgg Exp $
 /* ######################################################################
    
    CDROM Utilities - Some functions to manipulate CDROM mounts.
@@ -160,7 +160,7 @@ bool MountCdrom(string Path)
 // ---------------------------------------------------------------------
 /* We convert everything we hash into a string, this prevents byte size/order
    from effecting the outcome. */
-bool IdentCdrom(string CD,string &Res)
+bool IdentCdrom(string CD,string &Res,unsigned int Version)
 {
    MD5Summation Hash;
 
@@ -182,8 +182,19 @@ bool IdentCdrom(string CD,string &Res)
       if (strcmp(Dir->d_name,".") == 0 ||
          strcmp(Dir->d_name,"..") == 0)
         continue;
-   
-      sprintf(S,"%lu",Dir->d_ino);
+
+      if (Version <= 1)
+      {
+        sprintf(S,"%lu",Dir->d_ino);
+      }
+      else
+      {
+        struct stat Buf;
+        if (stat(Dir->d_name,&Buf) != 0)
+           continue;
+        sprintf(S,"%lu",Buf.st_mtime);
+      }
+      
       Hash.Add(S);
       Hash.Add(Dir->d_name);
    };
@@ -201,7 +212,8 @@ bool IdentCdrom(string CD,string &Res)
           (long)(Buf.f_bfree*(Buf.f_bsize/1024)));
    Hash.Add(S);
    
-   Res = Hash.Result().Value();
+   sprintf(S,"-%u",Version);
+   Res = Hash.Result().Value() + S;
    return true;   
 }
                                                                        /*}}}*/
index a9f4f926c364c6114a0a911006a7b60c135f3d6f..309857ddef851fecf274e43b3a76b62111d808ad 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: cdromutl.h,v 1.1 1998/11/29 01:19:27 jgg Exp $
+// $Id: cdromutl.h,v 1.2 1999/06/05 03:54:29 jgg Exp $
 /* ######################################################################
 
    CDROM Utilities - Some functions to manipulate CDROM mounts.
@@ -18,6 +18,6 @@
 
 bool MountCdrom(string Path);
 bool UnmountCdrom(string Path);
-bool IdentCdrom(string CD,string &Res);
+bool IdentCdrom(string CD,string &Res,unsigned int Version = 2);
 
 #endif
index a4446576668b7d2de0280f45ce2b2b8c3af67c12..68511dd5b202004bf249b658f0ac48a5046d11cf 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: cdrom.cc,v 1.9 1999/05/23 05:45:13 jgg Exp $
+// $Id: cdrom.cc,v 1.10 1999/06/05 03:54:29 jgg Exp $
 /* ######################################################################
 
    CDROM URI method for APT
@@ -68,7 +68,9 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
    URI Get = Itm->Uri;
    string File = Get.Path;
    FetchResult Res;
-   
+
+   bool Debug = _config->FindB("Debug::Acquire::cdrom",false);
+
    /* All IMS queries are returned as a hit, CDROMs are readonly so 
       time stamps never change */
    if (Itm->LastModified != 0)
@@ -114,13 +116,23 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
    string NewID;
    while (1)
    {
-      if (IdentCdrom(CDROM,NewID) == false)
-        return false;
-   
-      // A hit
-      if (Database.Find("CD::" + NewID) == Get.Host)
-        break;
-
+      bool Hit = false;
+      for (unsigned int Version = 2; Version != 0; Version--)
+      {
+        if (IdentCdrom(CDROM,NewID,Version) == false)
+           return false;
+        
+        if (Debug == true)
+           clog << "ID " << Version << " " << NewID << endl;
+      
+        // A hit
+        if (Database.Find("CD::" + NewID) == Get.Host)
+        {
+           Hit = true;
+           break;
+        }       
+      }
+      
       // I suppose this should prompt somehow?
       if (UnmountCdrom(CDROM) == false)
         return _error->Error("Unable to unmount the CD-ROM in %s, it may still be in use.",