summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-07-14 03:23:54 +0200
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-07-14 03:23:54 +0200
commit40d188eb6260d6e53154649fce3ae449477cc6bf (patch)
tree4b7b6bfcad0ce1bc93e0e8fc4cf9d12f9f8dcb80 /module
parent[Crypter] Set folder (diff)
downloadpyload-40d188eb6260d6e53154649fce3ae449477cc6bf.tar.xz
save_path and save_join renamed to safe_path and safe_join
Diffstat (limited to 'module')
-rw-r--r--module/PluginThread.py6
-rw-r--r--module/PyPackage.py4
-rw-r--r--module/network/HTTPDownload.py4
-rw-r--r--module/plugins/Plugin.py8
-rw-r--r--module/utils.py4
-rw-r--r--module/web/pyload_app.py8
6 files changed, 17 insertions, 17 deletions
diff --git a/module/PluginThread.py b/module/PluginThread.py
index 9f0955cb4..2d0a07e77 100644
--- a/module/PluginThread.py
+++ b/module/PluginThread.py
@@ -34,7 +34,7 @@ from pycurl import error
from PyFile import PyFile
from plugins.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload
from common.packagetools import parseNames
-from utils import save_join
+from utils import safe_join
from Api import OnlineStatus
class PluginThread(Thread):
@@ -64,11 +64,11 @@ class PluginThread(Thread):
for f in listdir(join("tmp", pyfile.pluginname)):
try:
# avoid encoding errors
- zip.write(join("tmp", pyfile.pluginname, f), save_join(pyfile.pluginname, f))
+ zip.write(join("tmp", pyfile.pluginname, f), safe_join(pyfile.pluginname, f))
except:
pass
- info = zipfile.ZipInfo(save_join(pyfile.pluginname, "debug_Report.txt"), gmtime())
+ info = zipfile.ZipInfo(safe_join(pyfile.pluginname, "debug_Report.txt"), gmtime())
info.external_attr = 0644 << 16L # change permissions
zip.writestr(info, dump)
diff --git a/module/PyPackage.py b/module/PyPackage.py
index ce1461241..775318049 100644
--- a/module/PyPackage.py
+++ b/module/PyPackage.py
@@ -18,7 +18,7 @@
"""
from module.PullEvents import UpdateEvent
-from module.utils import save_path
+from module.utils import safe_path
class PyPackage:
"""
@@ -39,7 +39,7 @@ class PyPackage:
@property
def folder(self):
- return save_path(self._folder)
+ return safe_path(self._folder)
def toDict(self):
""" Returns a dictionary representation of the data.
diff --git a/module/network/HTTPDownload.py b/module/network/HTTPDownload.py
index 767572231..809204070 100644
--- a/module/network/HTTPDownload.py
+++ b/module/network/HTTPDownload.py
@@ -29,7 +29,7 @@ from HTTPChunk import ChunkInfo, HTTPChunk
from HTTPRequest import BadHeader
from module.plugins.Plugin import Abort
-from module.utils import save_join, fs_encode
+from module.utils import safe_join, fs_encode
class HTTPDownload:
""" loads a url http + ftp """
@@ -114,7 +114,7 @@ class HTTPDownload:
fo.close()
if self.nameDisposition and self.disposition:
- self.filename = save_join(dirname(self.filename), self.nameDisposition)
+ self.filename = safe_join(dirname(self.filename), self.nameDisposition)
move(init, fs_encode(self.filename))
self.info.remove() #remove info file
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py
index 48b489552..51fa7c87c 100644
--- a/module/plugins/Plugin.py
+++ b/module/plugins/Plugin.py
@@ -31,7 +31,7 @@ if os.name != "nt":
from itertools import islice
-from module.utils import save_join, save_path, fs_encode, fs_decode
+from module.utils import safe_join, safe_path, fs_encode, fs_decode
def chunks(iterable, size):
it = iter(iterable)
@@ -483,7 +483,7 @@ class Plugin(Base):
download_folder = self.config['general']['download_folder']
- location = save_join(download_folder, self.pyfile.package().folder)
+ location = safe_join(download_folder, self.pyfile.package().folder)
if not exists(location):
makedirs(location, int(self.core.config["permission"]["folder"], 8))
@@ -499,7 +499,7 @@ class Plugin(Base):
# convert back to unicode
location = fs_decode(location)
- name = save_path(self.pyfile.name)
+ name = safe_path(self.pyfile.name)
filename = join(location, name)
@@ -598,7 +598,7 @@ class Plugin(Base):
raise SkipDownload(pyfile.pluginname)
download_folder = self.config['general']['download_folder']
- location = save_join(download_folder, pack.folder, self.pyfile.name)
+ location = safe_join(download_folder, pack.folder, self.pyfile.name)
if starting and self.core.config['download']['skip_existing'] and exists(location):
size = os.stat(location).st_size
diff --git a/module/utils.py b/module/utils.py
index 5a98b8d4a..94bf78054 100644
--- a/module/utils.py
+++ b/module/utils.py
@@ -39,7 +39,7 @@ def remove_chars(string, repl):
return string.translate(dict([(ord(s), None) for s in repl]))
-def save_path(name):
+def safe_path(name):
#remove some chars
name = name.encode('ascii', 'replace') # Non-ASCII chars usually breaks file saving. Replacing.
if os.name == 'nt':
@@ -49,7 +49,7 @@ def save_path(name):
return remove_chars(name, u'\0/\\"')
-def save_join(*args):
+def safe_join(*args):
""" joins a path, encoding aware """
return fs_encode(join(*[x if type(x) == unicode else decode(x) for x in args]))
diff --git a/module/web/pyload_app.py b/module/web/pyload_app.py
index 47b5507ca..76254b650 100644
--- a/module/web/pyload_app.py
+++ b/module/web/pyload_app.py
@@ -36,7 +36,7 @@ from utils import render_to_response, parse_permissions, parse_userdata, \
from filters import relpath, unquotepath
-from module.utils import formatSize, save_join, fs_encode, fs_decode
+from module.utils import formatSize, safe_join, fs_encode, fs_decode
# Helper
@@ -201,16 +201,16 @@ def downloads():
items = listdir(fs_encode(root))
for item in sorted([fs_decode(x) for x in items]):
- if isdir(save_join(root, item)):
+ if isdir(safe_join(root, item)):
folder = {
'name': item,
'path': item,
'files': []
}
- files = listdir(save_join(root, item))
+ files = listdir(safe_join(root, item))
for file in sorted([fs_decode(x) for x in files]):
try:
- if isfile(save_join(root, item, file)):
+ if isfile(safe_join(root, item, file)):
folder['files'].append(file)
except:
pass