示例#1
0
            b = encode_for_filesystem(u'')[0]
            t = Torrent(metainfo, b, b, self.config, self.data_dir,
                        self.rawserver, self.choker, self.singleport_listener,
                        self.up_ratelimiter, self.down_ratelimiter,
                        self.total_downmeasure, self.filepool, self.dht, self,
                        self.log_root)
            t.metainfo.reported_errors = True  # suppress redisplay on restart
            if infohash != t.metainfo.infohash:
                self.logger.error(
                    (_("Corrupt data in \"%s\", cannot restore torrent.") %
                     hashtext) + _("(infohash mismatch)"))
                return None
            if len(line) == 41:
                t.working_path = None
                t.destination_path = None
                return infohash, t
            try:
                if version < 2:
                    t.working_path = line[41:-1].decode('string_escape')
                    t.working_path = t.working_path.decode('utf-8')
                    t.working_path = encode_for_filesystem(t.working_path)[0]
                    t.destination_path = t.working_path
                elif version == 3:
                    up, down, working_path = line[41:-1].split(' ', 2)
                    t.uptotal = t.uptotal_old = int(up)
                    t.downtotal = t.downtotal_old = int(down)
                    t.working_path = working_path.decode('string_escape')
                    t.working_path = t.working_path.decode('utf-8')
                    t.working_path = encode_for_filesystem(t.working_path)[0]
                    t.destination_path = t.working_path
示例#2
0
            b = encode_for_filesystem(u'')[0]
            t = Torrent(metainfo, b, b, self.config, self.data_dir,
                        self.rawserver, self.choker,
                        self.singleport_listener, self.up_ratelimiter,
                        self.down_ratelimiter,
                        self.total_downmeasure, self.filepool, self.dht, self,
                        self.log_root)
            t.metainfo.reported_errors = True # suppress redisplay on restart
            if infohash != t.metainfo.infohash:
                self.logger.error((_("Corrupt data in \"%s\", cannot restore torrent.") % hashtext) +
                                  _("(infohash mismatch)"))
                return None
            if len(line) == 41:
                t.working_path = None
                t.destination_path = None
                return infohash, t
            try:
                if version < 2:
                    t.working_path = line[41:-1].decode('string_escape')
                    t.working_path = t.working_path.decode('utf-8')
                    t.working_path = encode_for_filesystem(t.working_path)[0]
                    t.destination_path = t.working_path
                elif version == 3:
                    up, down, working_path = line[41:-1].split(' ', 2)
                    t.uptotal = t.uptotal_old = int(up)
                    t.downtotal = t.downtotal_old = int(down)
                    t.working_path = working_path.decode('string_escape')
                    t.working_path = t.working_path.decode('utf-8')
                    t.working_path = encode_for_filesystem(t.working_path)[0]
                    t.destination_path = t.working_path