Ora il modulo autodetermina la posizione del file scaricato.

Leonardo [2010-06-25 12:51]
Ora il modulo autodetermina la posizione del file scaricato.
Filename
mlmanager.py
diff --git a/mlmanager.py b/mlmanager.py
index 1f99eb4..8460e16 100644
--- a/mlmanager.py
+++ b/mlmanager.py
@@ -38,12 +38,6 @@ error_recipients = [ "owner" ]
 # giving up.
 rsync_tries = 5

-# Directory in which files are stored. It should contain two directories:
-# 1) files: where simple files are stored, and
-# 2) directories: where directories downloaded via bittorrent (or similar)
-#    are stored.
-incoming = "/var/lib/mldonkey/incoming"
-
 # Set file extensions to match. You can add extensions in every category
 video_extensions   = ['avi', 'mpeg', 'mpg', 'mkv', 'm2v', 'divx', 'xvid']
 audio_extensions   = ['mp3', 'ogg', 'wav', 'flac', 'aac' ]
@@ -168,7 +162,8 @@ class Download():
       self._group = os.getenv("FILE_GROUP")

     self._owner = os.getenv("FILE_OWNER")
-    self._incoming = incoming
+
+    self._incoming = os.getenv("INCOMING")

     # This could be none, and if it's empty
     # we should set it to None
@@ -184,16 +179,11 @@ class Download():
       self._committed = True
     else:
       self.commit ()
-
+
     # Construct the path of the file; this will be the real
     # path after it will be committed!
-    self._dest_path = self._incoming
-    if not self._dest_path.endswith(os.path.sep):
-      self._dest_path += os.path.sep
-    if os.path.exists(self._dest_path + os.path.join("files", self._filename)):
-      self._dest_path += os.path.join("files", self._filename)
-    else:
-      self._dest_path += os.path.join("directories", self._filename)
+    self._dest_path = os.path.join(os.getenv("HOME"), self._incoming)
+    self._dest_path = os.path.join(self._dest_path, self._filename)

     # If we get called with a non-existant file as argument that
     # is really a problem.
ViewGit