diff --git a/run_page/garmin_sync_cn_global.py b/run_page/garmin_sync_cn_global.py index 8d4ab0cd58b..98a3ebe42d3 100644 --- a/run_page/garmin_sync_cn_global.py +++ b/run_page/garmin_sync_cn_global.py @@ -5,23 +5,13 @@ import argparse import asyncio -import logging import os import sys -import time -import traceback -import zipfile -from io import BytesIO -import aiofiles -import cloudscraper -import garth -import httpx + from config import FIT_FOLDER, GPX_FOLDER, JSON_FILE, SQL_FILE, config -from garmin_device_adaptor import wrap_device_info from garmin_sync import Garmin, get_downloaded_ids from garmin_sync import download_new_activities, gather_with_concurrency -from synced_data_file_logger import load_synced_activity_list, save_synced_activity_list from utils import make_activities_file if __name__ == "__main__": @@ -53,7 +43,9 @@ # If the activity is manually imported with a GPX, the GPX file will be synced # load synced activity list - synced_activity = load_synced_activity_list() + downloaded_fit = get_downloaded_ids(FIT_FOLDER) + downloaded_gpx = get_downloaded_ids(GPX_FOLDER) + downloaded_activity = list(set(downloaded_fit + downloaded_gpx)) folder = FIT_FOLDER # make gpx or tcx dir @@ -65,7 +57,7 @@ download_new_activities( secret_string_cn, auth_domain, - synced_activity, + downloaded_activity, is_only_running, folder, "fit", @@ -95,10 +87,6 @@ ) loop.run_until_complete(future) - # Save synced activity list for speeding up - synced_activity.extend(new_ids) - save_synced_activity_list(synced_activity) - # Step 2: # Generate track from fit/gpx file make_activities_file(SQL_FILE, GPX_FOLDER, JSON_FILE, file_suffix="gpx") diff --git a/run_page/synced_data_file_logger.py b/run_page/synced_data_file_logger.py index 5a7fb98efce..0fae0b797bc 100644 --- a/run_page/synced_data_file_logger.py +++ b/run_page/synced_data_file_logger.py @@ -12,11 +12,6 @@ def save_synced_data_file_list(file_list: list): json.dump(file_list, f) -def save_synced_activity_list(activity_list: list): - with open(SYNCED_ACTIVITY_FILE, "w") as f: - json.dump(activity_list, f) - - def load_synced_file_list(): if os.path.exists(SYNCED_FILE): with open(SYNCED_FILE, "r") as f: @@ -27,15 +22,3 @@ def load_synced_file_list(): pass return [] - - -def load_synced_activity_list(): - if os.path.exists(SYNCED_ACTIVITY_FILE): - with open(SYNCED_ACTIVITY_FILE, "r") as f: - try: - return json.load(f) - except Exception as e: - print(f"json load {SYNCED_ACTIVITY_FILE} \nerror {e}") - pass - - return []