From 7fb23f31ac129442f35d2d98a5ef3f0b387dc8e2 Mon Sep 17 00:00:00 2001
From: mkaay <mkaay@mkaay.de>
Date: Fri, 27 Nov 2009 23:51:44 +0100
Subject: updated xmlrpc methods

---
 module/file_list.py | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

(limited to 'module')

diff --git a/module/file_list.py b/module/file_list.py
index f3bfc0b8a..1bcfb8580 100644
--- a/module/file_list.py
+++ b/module/file_list.py
@@ -151,6 +151,9 @@ class File_List(object):
                 returns a free id
             """
             ids = []
+            for pypack in (packager.file_list.data["packages"] + packager.file_list.data["queue"]):
+                for pyf in pypack.links:
+                    ids.append(pyf.id)
             for pyfile in collector.file_list.data["collector"]:
                 ids.append(pyfile.id)
             id = 1
@@ -235,6 +238,20 @@ class File_List(object):
                     return ("queue", n, pypack)
             raise NoSuchElementException()
         
+        def _getFileFromID(packager, id):
+            """
+                returns PyLoadFile instance and position with given id
+            """
+            for n, pypack in enumerate(packager.file_list.data["packages"]):
+                for pyfile in pypack.files:
+                    if pyfile.id == id:
+                        return ("packages", n, pyfile, pypack, pid)
+            for n, pypack in enumerate(packager.file_list.data["queue"]):
+                for pyfile in pypack.files:
+                    if pyfile.id == id:
+                        return ("queue", n, pyfile, pypack, pid)
+            raise NoSuchElementException()
+        
         def addNewPackage(packager, package_name=None):
             pypack = PyLoadPackage()
             pypack.id = packager._getFreeID()
@@ -251,6 +268,17 @@ class File_List(object):
             finally:
                 packager.file_list.lock.release()
         
+        def removeFile(packager, id):
+            """
+                removes PyLoadFile instance with the given id from package
+            """
+            packager.file_list.lock.acquire()
+            try:
+                key, n, pyfile, pypack, pid = self._getFileFromID()
+                del pypack.files[n]
+            finally:
+                packager.file_list.lock.release()
+        
         def pushPackage2Queue(packager, id):
             packager.file_list.lock.acquire()
             try:
-- 
cgit v1.2.3