From 57145534cac4d2198445967c2b69dc26e4caf583 Mon Sep 17 00:00:00 2001 From: j Date: Wed, 27 Sep 2017 12:05:23 +0200 Subject: [PATCH] return document id without extra call --- pandora_client/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pandora_client/__init__.py b/pandora_client/__init__.py index 3683178..7cc5bff 100755 --- a/pandora_client/__init__.py +++ b/pandora_client/__init__.py @@ -866,12 +866,10 @@ class Client(object): did = self.find_document(oshash) if not did: url = '%supload/document/' % self._config['url'] - r = self.api.upload_chunks(url, f, { + did = self.api.upload_chunks(url, f, { 'filename': os.path.basename(f) }) - if r and item: - did = self.find_document(oshash) - if item: + if did and item: r = self.api.addDocument({ 'id': did, 'item': item @@ -1210,7 +1208,10 @@ class API(ox.API): print(' ' * 80) print('') show_cursor() - return data and 'result' in data and data.get('result') == 1 + if data and 'result' in data and data.get('result') == 1: + return data.get('id', True) + else: + return False else: if DEBUG: if 'status' in data and data['status']['code'] == 401: