From 6a71fc3ca552629e772a17dc25e968bb02605976 Mon Sep 17 00:00:00 2001 From: dobefore <1432338032@qq.com> Date: Mon, 13 Sep 2021 11:33:12 +0800 Subject: [PATCH] fix_repeat_is_list --- src/ankisyncd/full_sync.py | 2 +- src/ankisyncd/sync.py | 2 +- src/ankisyncd/sync_app.py | 15 +++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/ankisyncd/full_sync.py b/src/ankisyncd/full_sync.py index a6c9b9d..7050a14 100644 --- a/src/ankisyncd/full_sync.py +++ b/src/ankisyncd/full_sync.py @@ -23,7 +23,7 @@ class FullSyncManager: "Integrity check failed for uploaded collection database file." ) - def upload(self, col: Collection, data: bytes, session) -> str: + def upload(self, col: Collection, data: bytes, session) : """ Uploads a sqlite database from the client to the sync server. diff --git a/src/ankisyncd/sync.py b/src/ankisyncd/sync.py index b8a9b8d..7ddabd9 100644 --- a/src/ankisyncd/sync.py +++ b/src/ankisyncd/sync.py @@ -151,7 +151,7 @@ select id from notes where mid = ?) limit 1""" self.col.db.scalar("select count() from graves"), len(self.col.models.all()), len(self.col.decks.all()), - len(self.col.decks.allConf()), + len(self.col.decks.all_config()), ] def usnLim(self): diff --git a/src/ankisyncd/sync_app.py b/src/ankisyncd/sync_app.py index 1ac5418..960dc01 100644 --- a/src/ankisyncd/sync_app.py +++ b/src/ankisyncd/sync_app.py @@ -141,13 +141,15 @@ class SyncCollectionHandler(Syncer): def sanityCheck2(self, client): server = self.sanityCheck() + status="ok" if client != server: logger.info( f"sanity check failed with server: {server} client: {client}" ) + status='bad' + + return dict(status, c=client, s=server) - return dict(status="bad", c=client, s=server) - return dict(status="ok") def finish(self): return super().finish(anki.utils.intTime(1000)) @@ -418,13 +420,12 @@ class Requests(object): if input is None: return if env.get('HTTP_TRANSFER_ENCODING','0') == 'chunked': - bd=b'' size = int(input.readline(),16) while size > 0: - bd += (input.read(size+2)).strip() + body += (input.read(size+2)).strip() size = int(input.readline(),16) - repeat=re.findall(b'^(.*?)Content-Disposition: form-data; name="data"',bd,re.MULTILINE) - items=re.split(repeat,bd) + repeat=re.findall(b'^(.*?)Content-Disposition: form-data; name="data"',body,re.MULTILINE)[0] + items=re.split(repeat,body) # del first ,last item items.pop() items.pop(0) @@ -655,6 +656,8 @@ class SyncApp: elif url == 'upload': thread = session.get_thread() result = thread.execute(self.operation_upload, [data['data'], session]) + print('#### from call') + print(result) resp=Response(json.dumps(result)) return resp(env,start_resp)