Commits

Donald Stufft committed 792b4a0

Use the filename to do the lookup

Comments (0)

Files changed (2)

         tally = cursor.fetchall()
         return releases, tally
 
+    def get_package_from_filename(self, filename):
+        query = """
+            SELECT name FROM release_files
+            WHERE filename = %s
+            LIMIT 1
+        """
+        cursor = self.get_cursor()
+        cursor.execute(query)
+        results = cursor.fetchall()
+        if results:
+            return results[0][0]
+
     #
     # File handling
     #
 import redis
 import rq
 
-from distlib.util import split_filename
-
 try:
     import json
 except ImportError:
         self.handler.send_response(200, 'OK')
 
 
-        filename, _ = os.path.splitext(os.path.basename(path))
-        package, _, _ = split_filename(filename)
-
-        if package:
+        filename, _ = os.path.basename(path)
+
+        if filename:
             # Make sure that we associate the delivered file with the serial this
             # is valid for. Intended to support mirrors to more easily achieve
             # consistency with files that are newer than they may expect.
-            packages = self.store.find_package(package)
-            if packages:
-                serial = self.store.last_serial_for_package(packages[0])
+            package = self.store.get_package_from_filename(filename)
+            if package:
+                serial = self.store.last_serial_for_package(package)
                 if serial is not None:
                     self.handler.send_header("X-PYPI-LAST-SERIAL", str(serial))
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.