diff --git a/mattermost-dl.py b/mattermost-dl.py index 54f736f..c75d39b 100644 --- a/mattermost-dl.py +++ b/mattermost-dl.py @@ -326,7 +326,12 @@ def export_channel(d: Driver, channel: str, user_id_to_name: Dict[str, str], out print("Exporting channel", channel_name) after_ts = _parse_filter_timestamp(after) if after else None before_ts = _parse_filter_timestamp(before) if before else None - if after: + filtered_channel_name = ''.join(filter(lambda ch: ch not in "?!/\\.;:*\"<>|", channel_name)) + output_filepath = pathlib.Path(output_base) / channel_name / (filtered_channel_name + ".json") + if merge and after_ts is not None and not output_filepath.exists(): + print(" no existing export for this channel, fetching full history") + after_ts = None + elif after: print(f" fetching posts after {after}") # Get all posts for selected channel @@ -416,7 +421,6 @@ def export_channel(d: Driver, channel: str, user_id_to_name: Dict[str, str], out simple_post["files"] = filenames simple_posts.append(simple_post) - filtered_channel_name = ''.join(filter(lambda ch: ch not in "?!/\\.;:*\"<>|", channel_name)) output_filename = filtered_channel_name + ".json" output_filepath = output_base / output_filename