From 63d9fa12a205b5c770e75c09be1a0a9656eb1ea1 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 2 Oct 2011 21:01:32 +0200 Subject: fixed urlmatcher, clear links on start option --- module/Api.py | 5 +++-- module/database/FileDatabase.py | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'module') diff --git a/module/Api.py b/module/Api.py index 66ba855f1..3480f05b8 100644 --- a/module/Api.py +++ b/module/Api.py @@ -45,7 +45,7 @@ def permission(bits): return _Dec -urlmatcher = re.compile(r"((https?|ftps?|xdcc|sftp):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)", re.IGNORECASE) +urlmatcher = re.compile(r"((https?|ftps?|xdcc|sftp):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+\-=\\\.&]*)", re.IGNORECASE) class PERMS: ALL = 0 # requires no permission, but login @@ -338,7 +338,8 @@ class Api(Iface): page = getURL(url) urls += [x[0] for x in urlmatcher.findall(page)] - return self.checkURLs(urls) + # remove duplicates + return self.checkURLs(set(urls)) @permission(PERMS.ADD) diff --git a/module/database/FileDatabase.py b/module/database/FileDatabase.py index 2ca7fd07d..91213d8a6 100644 --- a/module/database/FileDatabase.py +++ b/module/database/FileDatabase.py @@ -863,6 +863,11 @@ class FileMethods(): self.c.execute("SELECT l.plugin FROM links as l INNER JOIN packages as p ON l.package=p.id AND p.folder=? WHERE l.id!=? AND l.status=0 AND l.name=?", (folder, id, filename)) return self.c.fetchone() + @style.queue + def purgeLinks(self): + self.c.execute("DELETE FROM links;") + self.c.execute("DELETE FROM packages;") + DatabaseBackend.registerSub(FileMethods) if __name__ == "__main__": -- cgit v1.2.3