From 2ce461ed6a5d1aea563c15a5b001f0e1bff40ee4 Mon Sep 17 00:00:00 2001 From: fyears Date: Fri, 10 Dec 2021 00:11:53 +0800 Subject: [PATCH] allow multi pages in dropbox --- src/remoteForDropbox.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/remoteForDropbox.ts b/src/remoteForDropbox.ts index c9d453c..d9e1506 100644 --- a/src/remoteForDropbox.ts +++ b/src/remoteForDropbox.ts @@ -481,20 +481,41 @@ export const listFromRemote = async ( throw Error("prefix not supported (yet)"); } await client.init(); - const res = await client.dropbox.filesListFolder({ + let res = await client.dropbox.filesListFolder({ path: `/${client.vaultName}`, recursive: true, + include_deleted: false, + limit: 1000, }); if (res.status !== 200) { throw Error(JSON.stringify(res)); } // console.log(res); + const contents = res.result.entries; const unifiedContents = contents .filter((x) => x[".tag"] !== "deleted") .filter((x) => x.path_display !== `/${client.vaultName}`) .map((x) => fromDropboxItemToRemoteItem(x, client.vaultName)); + + while (res.result.has_more) { + res = await client.dropbox.filesListFolderContinue({ + cursor: res.result.cursor, + }); + if (res.status !== 200) { + throw Error(JSON.stringify(res)); + } + + const contents2 = res.result.entries; + const unifiedContents2 = contents2 + .filter((x) => x[".tag"] !== "deleted") + .filter((x) => x.path_display !== `/${client.vaultName}`) + .map((x) => fromDropboxItemToRemoteItem(x, client.vaultName)); + unifiedContents.push(...unifiedContents2); + } + fixLastModifiedTimeInplace(unifiedContents); + return { Contents: unifiedContents, };