diff options
| author | Nathan | 2010-11-03 12:39:05 -0600 |
|---|---|---|
| committer | Nathan | 2010-11-03 12:39:05 -0600 |
| commit | c2c373e8d4efbf13234114e2ca343e2bed9e616d (patch) | |
| tree | 015afbee717168ecfa1be567326192b113cc66ce | |
| parent | c123920cfe59b8465153ab695ba10f5b263554ab (diff) | |
| download | amazons3-py-c2c373e8d4efbf13234114e2ca343e2bed9e616d.tar.gz amazons3-py-c2c373e8d4efbf13234114e2ca343e2bed9e616d.zip | |
Fixed 'size' function for existing files.
| -rw-r--r-- | django/__init__.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/django/__init__.py b/django/__init__.py index 9f9836c..7386594 100644 --- a/django/__init__.py +++ b/django/__init__.py | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | import os | ||
| 1 | from django.conf import settings | 2 | from django.conf import settings |
| 2 | from amazons3 import S3 | 3 | from amazons3 import S3 |
| 3 | 4 | ||
| @@ -39,7 +40,6 @@ class S3Storage(Storage): | |||
| 39 | return True | 40 | return True |
| 40 | 41 | ||
| 41 | def exists(self, filename): | 42 | def exists(self, filename): |
| 42 | import os | ||
| 43 | contents = self.conn.list_bucket(self.options['bucket'], {'prefix': os.path.dirname(filename)}) | 43 | contents = self.conn.list_bucket(self.options['bucket'], {'prefix': os.path.dirname(filename)}) |
| 44 | if filename in [f.key for f in contents.entries]: | 44 | if filename in [f.key for f in contents.entries]: |
| 45 | return True | 45 | return True |
| @@ -47,9 +47,9 @@ class S3Storage(Storage): | |||
| 47 | return False | 47 | return False |
| 48 | 48 | ||
| 49 | def size(self, filename): | 49 | def size(self, filename): |
| 50 | contents = self.conn.list_bucket(self.options['bucket']) | 50 | contents = self.conn.list_bucket(self.options['bucket'], {'prefix': os.path.dirname(filename)} ) |
| 51 | for f in contents.entries: | 51 | for f in contents.entries: |
| 52 | if f.name == filename: | 52 | if f.key == filename: |
| 53 | return f.size | 53 | return f.size |
| 54 | 54 | ||
| 55 | return False | 55 | return False |