Feature/Bug #519 - CloudFilesStorage.get_file() performance issue - Fix
authorJoar Wandborg <git@wandborg.com>
Wed, 24 Aug 2011 23:05:49 +0000 (01:05 +0200)
committerJoar Wandborg <git@wandborg.com>
Wed, 24 Aug 2011 23:05:49 +0000 (01:05 +0200)
*   `CloudFilesStorage.get_file()` now guesses the filepath without connecting to cloudfiles. Huge profits for xDSL-hosted or slow net machines.

mediagoblin/storage.py

index d484be1fed5fd5313712a42f87eb1f5e90d9f8ca..7ada95e1165c3d177a37993066f715bdb4449ff9 100644 (file)
@@ -254,6 +254,8 @@ class CloudFilesStorage(StorageInterface):
             self.container = self.connection.get_container(
                 self.param_container)
 
+        self.container_uri = self.container.public_uri()
+
     def _resolve_filepath(self, filepath):
         return '/'.join(
             clean_listy_filepath(filepath))
@@ -282,7 +284,9 @@ class CloudFilesStorage(StorageInterface):
         self.container.delete_object(filepath)
 
     def file_url(self, filepath):
-        return self.get_file(filepath).public_uri()
+        return '/'.join([
+                self.container_uri,
+                self._resolve_filepath(filepath)])
 
 
 class MountStorage(StorageInterface):