aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2011-04-09 14:05:44 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2011-04-09 14:05:44 -0500
commit0b9cf289c3f479ba1acb728b5aa6ec2e1d8b4e49 (patch)
tree793d182e69969a332caaa01b6c51d57d0054cd9d
parent797be93ca678c7c0735b0041cf43089d227a6a1c (diff)
downloadmediagoblin-0b9cf289c3f479ba1acb728b5aa6ec2e1d8b4e49.tar.lz
mediagoblin-0b9cf289c3f479ba1acb728b5aa6ec2e1d8b4e49.tar.xz
mediagoblin-0b9cf289c3f479ba1acb728b5aa6ec2e1d8b4e49.zip
Actually, we can implement get_unique_filename, which should be the
same across all storage API implementations
-rw-r--r--mediagoblin/storage.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/mediagoblin/storage.py b/mediagoblin/storage.py
index cd61a6aa..3b6a7a2a 100644
--- a/mediagoblin/storage.py
+++ b/mediagoblin/storage.py
@@ -84,6 +84,14 @@ class StorageInterface(object):
# Subclasses should override this method.
self.__raise_not_implemented()
+ def get_file(self, filepath):
+ # Subclasses should override this method.
+ self.__raise_not_implemented()
+
+ def delete_file(self, filepath):
+ # Subclasses should override this method.
+ self.__raise_not_implemented()
+
def get_unique_filename(self, filepath):
"""
If a filename at filepath already exists, generate a new name.
@@ -96,13 +104,7 @@ class StorageInterface(object):
>>> storage_handler.get_unique_filename(['dir1', 'dir2', 'fname.jpg'])
['dir1', 'dir2', 'd02c3571-dd62-4479-9d62-9e3012dada29-fname.jpg']
"""
- # Subclasses should override this method.
- self.__raise_not_implemented()
-
- def get_file(self, filepath):
- # Subclasses should override this method.
- self.__raise_not_implemented()
-
- def delete_file(self, filepath):
- # Subclasses should override this method.
- self.__raise_not_implemented()
+ if self.file_exists(filepath):
+ return filepath[:-1] + ["%s-%s" % (uuid.uuid4(), filepath[-1])]
+ else:
+ return filepath