summaryrefslogtreecommitdiffstats
path: root/module/file_list.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-06-23 00:33:49 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-06-23 00:33:49 +0200
commit967a43fd6680b5db0d3494e31d09549b58b30640 (patch)
tree165ab029311f24b0f3e6764d26c17a002d6c9260 /module/file_list.py
parentreconnect works with new plugin system (diff)
downloadpyload-967a43fd6680b5db0d3494e31d09549b58b30640.tar.xz
cli able to delete links in queue
Diffstat (limited to 'module/file_list.py')
-rw-r--r--module/file_list.py30
1 files changed, 23 insertions, 7 deletions
diff --git a/module/file_list.py b/module/file_list.py
index d2a634645..8f32ef474 100644
--- a/module/file_list.py
+++ b/module/file_list.py
@@ -18,7 +18,7 @@
#
###
-LIST_VERSION = 1
+LIST_VERSION = 2
import cPickle
from Py_Load_File import PyLoadFile
@@ -28,7 +28,7 @@ class File_List(object):
def __init__(self, core):
self.core = core
self.files = []
- self.data = {'version': LIST_VERSION}
+ self.data = {'version': LIST_VERSION, 'order': []}
self.load()
def new_pyfile(self, url):
@@ -46,6 +46,7 @@ class File_List(object):
new_file = self.new_pyfile(url)
self.files.append(new_file)
self.data[new_file.id] = Data(url)
+ self.data['order'].append(new_file.id)
def extend(self, urls):
for url in urls:
@@ -56,8 +57,24 @@ class File_List(object):
if pyfile in self.files:
self.files.remove(pyfile)
+ self.data['order'].remove(pyfile.id)
del self.data[pyfile.id]
+ def remove_id(self, pyid):
+ pyid = int(pyid)
+ found = False
+ for pyfile in self.files:
+ if pyfile.id == pyid:
+ self.files.remove(pyfile)
+ found = True
+ break
+
+ if not found:
+ return False
+
+ self.data['order'].remove(pyid)
+ del self.data[pyid]
+
def get_id(self):
"""return a free id"""
id = 1
@@ -77,14 +94,13 @@ class File_List(object):
pkl_file = open('links.pkl', 'rb')
obj = cPickle.load(pkl_file)
except:
- obj = {'version': LIST_VERSION}
+ obj = {'version': LIST_VERSION, 'order': []}
if obj['version'] < LIST_VERSION:
- obj = {'version': LIST_VERSION}
+ obj = {'version': LIST_VERSION, 'order': []}
- for key, value in obj.iteritems():
- if key != 'version':
- self.append(value.url)
+ for i in obj['order']:
+ self.append(obj[i].url)
self.core.logger.info("Links loaded: "+ str(int(len(obj) - 1)))