diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2014-04-19 15:31:18 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2014-04-19 15:31:41 +0200 |
commit | 313bad0316684fed4d1e347ebbb4e42e4e6e49dd (patch) | |
tree | 7f215acaa2a70eb36abee66979fe5fbb70592930 /pyload/api | |
parent | Updated translations (diff) | |
download | pyload-313bad0316684fed4d1e347ebbb4e42e4e6e49dd.tar.xz |
major bugfix for link and packing adding
Diffstat (limited to 'pyload/api')
-rw-r--r-- | pyload/api/DownloadApi.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/pyload/api/DownloadApi.py b/pyload/api/DownloadApi.py index 299609e35..df573c6bb 100644 --- a/pyload/api/DownloadApi.py +++ b/pyload/api/DownloadApi.py @@ -3,15 +3,21 @@ from os.path import isabs -from pyload.Api import Api, RequirePerm, Permission +from pyload.Api import Api, RequirePerm, Permission, Role from pyload.utils.fs import join from ApiComponent import ApiComponent - class DownloadApi(ApiComponent): """ Component to create, add, delete or modify downloads.""" + # TODO: workaround for link adding without owner + def truePrimary(self): + if self.user: + return self.user.true_primary + else: + return self.core.db.getUserData(role=Role.Admin).uid + @RequirePerm(Permission.Add) def createPackage(self, name, folder, root, password="", site="", comment="", paused=False): """Create a new package. @@ -32,7 +38,7 @@ class DownloadApi(ApiComponent): folder = folder.replace("http://", "").replace(":", "").replace("\\", "_").replace("..", "") self.core.log.info(_("Added package %(name)s as folder %(folder)s") % {"name": name, "folder": folder}) - pid = self.core.files.addPackage(name, folder, root, password, site, comment, paused, self.user.true_primary) + pid = self.core.files.addPackage(name, folder, root, password, site, comment, paused, self.truePrimary()) return pid @@ -76,7 +82,7 @@ class DownloadApi(ApiComponent): """ hoster, crypter = self.core.pluginManager.parseUrls(links) - self.core.files.addLinks(hoster + crypter, pid, self.user.true_primary) + self.core.files.addLinks(hoster + crypter, pid, self.truePrimary()) if hoster: self.core.threadManager.createInfoThread(hoster, pid) |