summaryrefslogtreecommitdiffstats
path: root/module/file_list.py
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2009-11-27 23:51:44 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2009-11-27 23:51:44 +0100
commit7fb23f31ac129442f35d2d98a5ef3f0b387dc8e2 (patch)
tree5d28138f06a75130dd343dc609207b182af80f65 /module/file_list.py
parentfixed file_list (diff)
downloadpyload-7fb23f31ac129442f35d2d98a5ef3f0b387dc8e2.tar.xz
updated xmlrpc methods
Diffstat (limited to 'module/file_list.py')
-rw-r--r--module/file_list.py28
1 files changed, 28 insertions, 0 deletions
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: