Module: deluge
Branch: master
Commit: efecf38bcd2011f4e784783db94bffd0b8b468e0

Author: Andrew Resch <[email protected]>
Date:   Thu Jul 15 10:50:15 2010 -0700

Attempt to create a move_storage destination path if it doesn't exist

---

 deluge/core/torrent.py |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py
index 1768a37..d19cbb4 100644
--- a/deluge/core/torrent.py
+++ b/deluge/core/torrent.py
@@ -798,8 +798,13 @@ class Torrent(object):
     def move_storage(self, dest):
         """Move a torrent's storage location"""
         if not os.path.exists(dest):
-            log.error("Could not move storage for torrent %s since %s does not 
exist!", self.torrent_id, dest)
-            return False
+            try:
+                # Try to make the destination path if it doesn't exist
+                os.makedirs(dest)
+            except IOError, e:
+                log.exception(e)
+                log.error("Could not move storage for torrent %s since %s does 
not exist and could not create the directory.", self.torrent_id, dest)
+                return False
         try:
             self.handle.move_storage(dest.encode("utf8"))
         except:

-- 
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.

Reply via email to