summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/web/pyload/views.py34
-rwxr-xr-xpyLoadCore.py22
2 files changed, 30 insertions, 26 deletions
diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py
index e6428d146..f6175f338 100644
--- a/module/web/pyload/views.py
+++ b/module/web/pyload/views.py
@@ -88,25 +88,29 @@ def queue(request):
@permission('pyload.can_download')
@check_server
def downloads(request):
- if not isdir(settings.DL_ROOT):
+
+ root = settings.PYLOAD.get_conf_val("general", "download_folder")
+
+ if not isdir(root):
return base(request, [_('Download directory not found.')])
data = {
'folder': [],
'files': []
}
- for item in listdir(settings.DL_ROOT):
- if isdir(join(settings.DL_ROOT, item)):
+ for item in listdir(root):
+ if isdir(join(root, item)):
folder = {
'name': item,
+ 'path': item,
'files': []
}
- for file in listdir(join(settings.DL_ROOT, item)):
- if isfile(join(settings.DL_ROOT, item, file)):
+ for file in listdir(join(root, item)):
+ if isfile(join(root, item, file)):
folder['files'].append(file)
data['folder'].append(folder)
- elif isfile(join(settings.DL_ROOT, item)):
+ elif isfile(join(root, item)):
data['files'].append(item)
@@ -118,8 +122,10 @@ def downloads(request):
def download(request, path):
path = unquote(path)
path = path.split("/")
-
- dir = join(settings.DL_ROOT, path[1].replace('..', ''))
+
+ root = settings.PYLOAD.get_conf_val("general", "download_folder")
+
+ dir = join(root, path[1].replace('..', ''))
if isdir(dir) or isfile(dir):
if isdir(dir): filepath = join(dir, path[2])
elif isfile(dir): filepath = dir
@@ -148,14 +154,14 @@ def download(request, path):
@permission('pyload.can_see_logs')
@check_server
def logs(request, page=0):
-
- log = file(join(settings.LOG_ROOT, "log.txt")).readlines()
- log.reverse()
- data = []
+
page = int(page)
+ log = settings.PYLOAD.get_log(page)
+ data = []
+
try:
- for i in range(page, page + 20):
- data.append({'line': i + 1, 'content':log[i]})
+ for i in range(0, 20):
+ data.append({'line': i + 1+page, 'content':log[i]})
except:
pass
diff --git a/pyLoadCore.py b/pyLoadCore.py
index 02975ad2f..bfc575b94 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -421,7 +421,7 @@ class ServerMethods():
def get_conf_val(self, cat, var):
""" get config value """
- return self.config[cat][var]
+ return self.core.config[cat][var]
def set_conf_val(self, cat, opt, val):
""" set config value """
@@ -539,25 +539,23 @@ class ServerMethods():
def get_log(self, offset=0):
filename = join(self.core.config['log']['log_folder'], 'log.txt')
fh = open(filename, "r")
- content = fh.read()
+ lines = fh.readlines()
fh.close()
- lines = content.splitlines()
+ lines.reverse()
if offset >= len(lines):
return None
+
return lines[offset:]
def stop_downloads(self):
- #@TODO implement
- self.core.thread_list.stopAllDownloads()
+ pyfiles = self.files.cache.values()
+
+ for pyfile in pyfiles:
+ pyfile.abortDownload()
def stop_download(self, type, id):
- #@TODO implement
- if type == "pack":
- ids = self.core.file_list.getPackageFiles(id)
- for fid in ids:
- self.core.file_list.packager.abortFile(fid)
- else:
- self.core.file_list.packager.abortFile(id)
+ if self.core.files.cache.has_key(id):
+ self.core.files.cache[id].abortDownload()
def set_package_name(self, pid, name):