diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-08-04 00:40:05 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-08-04 00:40:05 +0200 |
commit | 3cb314365ca59f73e131bd8488f708f5b5dba5ce (patch) | |
tree | 5ccd1358bb588e6a984b46e9f58424fe7b8ed28f | |
parent | api fix (diff) | |
download | pyload-3cb314365ca59f73e131bd8488f708f5b5dba5ce.tar.xz |
option to skip if file exists
-rw-r--r-- | module/config/default.conf | 1 | ||||
-rw-r--r-- | module/plugins/Plugin.py | 17 |
2 files changed, 12 insertions, 6 deletions
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) |