From 3cb314365ca59f73e131bd8488f708f5b5dba5ce Mon Sep 17 00:00:00 2001 From: RaNaN Date: Thu, 4 Aug 2011 00:40:05 +0200 Subject: option to skip if file exists --- module/config/default.conf | 1 + module/plugins/Plugin.py | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'module') diff --git a/module/config/default.conf b/module/config/default.conf index 78097e8f1..434e85a7c 100644 --- a/module/config/default.conf +++ b/module/config/default.conf @@ -35,6 +35,7 @@ download - "Download": bool limit_speed : "Limit Download Speed" = False str interface : "Download interface to bind (ip or Name)" = None bool ipv6 : "Allow IPv6" = False + bool skip_existing : "Skip already existing files" = False permission - "Permissions": bool change_user : "Change user of running process" = False str user : "Username" = user diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index 94e2b0aca..1e0f15b33 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -535,20 +535,25 @@ class Plugin(object): pack = self.pyfile.package() - cache = self.core.files.cache.values() - - for pyfile in cache: + for pyfile in self.core.files.cache.values(): if pyfile != self.pyfile and pyfile.name == self.pyfile.name and pyfile.package().folder == pack.folder: if pyfile.status in (0, 12): #finished or downloading raise SkipDownload(pyfile.pluginname) elif pyfile.status in (5, 7) and starting: #a download is waiting/starting and was appenrently started before raise SkipDownload(pyfile.pluginname) + + download_folder = self.config['general']['download_folder'] + location = save_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 + if size >= self.pyfile.size: + raise SkipDownload("File exists.") + pyfile = self.core.db.findDuplicates(self.pyfile.id, self.pyfile.package().folder, self.pyfile.name) if pyfile: - download_folder = self.config['general']['download_folder'] - location = save_join(download_folder, pack.folder) - if exists(join(location, fs_encode(self.pyfile.name))): + if exists(location): raise SkipDownload(pyfile[0]) self.log.debug("File %s not skipped, because it does not exists." % self.pyfile.name) -- cgit v1.2.3