def parse_allowed(self): self.rawserver.add_task(self.parse_allowed, self.parse_dir_interval) if self.config['allowed_dir']: r = parsedir(self.config['allowed_dir'], self.allowed, self.allowed_dir_files, self.allowed_dir_blocked, [".torrent"]) (self.allowed, self.allowed_dir_files, self.allowed_dir_blocked, added) = r[:-1] self.state['allowed'] = self.allowed self.state['allowed_dir_files'] = self.allowed_dir_files self.t2tlist.parse(self.allowed) else: f = self.config['allowed_list'] if self.allowed_list_mtime == os.path.getmtime(f): return try: r = parsetorrentlist(f, self.allowed) (self.allowed, added) = r self.state['allowed_list'] = self.allowed except (IOError, OSError): print '**warning** unable to read allowed torrent list' return self.allowed_list_mtime = os.path.getmtime(f) for infohash in added: self.downloads.setdefault(infohash, {}) self.completed.setdefault(infohash, 0) self.seedcount.setdefault(infohash, 0)
def scan(self): self.rawserver.add_task(self.scan, self.scan_period) r = parsedir(self.torrent_dir, self.torrent_cache, self.file_cache, self.blocked_files, return_metainfo=True, errfunc=self.Output.message) (self.torrent_cache, self.file_cache, self.blocked_files, added, removed) = r for hash, data in removed.items(): self.Output.message('dropped "{}"'.format(data['path'])) self.remove(hash) for hash, data in added.items(): self.Output.message('added "{}"'.format(data['path'])) self.add(hash, data)
def scan(self): self.rawserver.add_task(self.scan, self.scan_period) r = parsedir(self.torrent_dir, self.torrent_cache, self.file_cache, self.blocked_files, return_metainfo=True, errfunc=self.Output.message) (self.torrent_cache, self.file_cache, self.blocked_files, added, removed) = r for hash, data in removed.iteritems(): self.Output.message('dropped "{}"'.format(data['path'])) self.remove(hash) for hash, data in added.iteritems(): self.Output.message('added "{}"'.format(data['path'])) self.add(hash, data)