aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tools/files.py
diff options
context:
space:
mode:
authorBrett Smith <brettcsmith@brettcsmith.org>2012-07-08 11:07:02 -0400
committerBrett Smith <brettcsmith@brettcsmith.org>2012-07-08 11:07:02 -0400
commit81d3c4cf1cee923c4b803a96b6f5628e9aa9b78d (patch)
tree0361e85a142b3574b0de28f172fdcf57f21bb6ee /mediagoblin/tools/files.py
parent9c7688667e9a5e96fbf54900976834b4ecf2b033 (diff)
parenta122357ee75d0abf215b552f0923de1fd722f6de (diff)
downloadmediagoblin-81d3c4cf1cee923c4b803a96b6f5628e9aa9b78d.tar.lz
mediagoblin-81d3c4cf1cee923c4b803a96b6f5628e9aa9b78d.tar.xz
mediagoblin-81d3c4cf1cee923c4b803a96b6f5628e9aa9b78d.zip
Merge branch 'master' into 201207-testfixes
Diffstat (limited to 'mediagoblin/tools/files.py')
-rw-r--r--mediagoblin/tools/files.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/mediagoblin/tools/files.py b/mediagoblin/tools/files.py
index 25c1a6e6..fd38f05e 100644
--- a/mediagoblin/tools/files.py
+++ b/mediagoblin/tools/files.py
@@ -16,6 +16,7 @@
from mediagoblin import mg_globals
+
def delete_media_files(media):
"""
Delete all files associated with a MediaEntry
@@ -23,10 +24,20 @@ def delete_media_files(media):
Arguments:
- media: A MediaEntry document
"""
+ no_such_files = []
for listpath in media.media_files.itervalues():
- mg_globals.public_store.delete_file(
- listpath)
+ try:
+ mg_globals.public_store.delete_file(
+ listpath)
+ except OSError:
+ no_such_files.append("/".join(listpath))
for attachment in media.attachment_files:
- mg_globals.public_store.delete_file(
- attachment['filepath'])
+ try:
+ mg_globals.public_store.delete_file(
+ attachment['filepath'])
+ except OSError:
+ no_such_files.append("/".join(attachment))
+
+ if no_such_files:
+ raise OSError(", ".join(no_such_files))