felixrieseberg/slack-archive

`downloadFilesForChannel` not downloading files for channel

Closed this issue · 1 comments

For one of my channels that has messages and files, no files were being downloaded
Upon inspection, the results of getMessages is always an empty array

Looking at how downloadMessages runs, it's only after paginating through the pagination loop

for await (const page of getWebClient().paginate("conversations.history", {
channel: channel.id,
oldest,
})) {
if (isConversation(page)) {
const pageLength = page.messages?.length || 0;
const fetched = `Fetched ${pageLength} messages`;
const total = `(total so far: ${result.messages.length + pageLength}`;
spinner.text = `Downloading ${
i + 1
}/${channelCount} ${name}: ${fetched} ${total})`;
result.new = result.new + (page.messages || []).length;
result.messages.unshift(...(page.messages || []));
}
}
that result.messages has a value

ah, getMessages fetches messages from the downloaded JSON file, and when downloadFilesForChannel runs, the file doesn't exist yet