Ian Lewis committed 8b3bdf4

Use the new_key method as someone might have changed the key_class on the bucket.

Comments (0)

Files changed (1)


     def exists(self, name):
         name = self._clean_name(name)
-        k = Key(self.bucket, name)
+        k = self.bucket.new_key(name)
         return k.exists()
     def listdir(self, name):
-        name = self._clean_name(name)
-        return [ for l in self.bucket.list() if not len(name) or[:len(name)] == name]
+        dirlist = self._bucket.list(name)
+        files = []
+        dirs = set()
+        base_parts = name.split("/") if name else []
+        for item in dirlist:
+            parts ="/")
+            parts = parts[len(base_parts):]
+            if len(parts) == 1:
+                # File 
+                files.append(parts[0])
+            elif len(parts) > 1:
+                # Directory
+                dirs.add(parts[0])
+        return list(dirs),files
     def size(self, name):
         name = self._clean_name(name)
         return self.bucket.get_key(name).size
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
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.