Skip to content

Commit

Permalink
fixed the bug where incremental uploads failed for not storing synced…
Browse files Browse the repository at this point in the history
…_activity in GitHub cache in sync_garmin_cn_global mode (yihong0618#734)
  • Loading branch information
NaturezzZ authored Nov 12, 2024
1 parent d1244e4 commit afe2b25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
22 changes: 5 additions & 17 deletions run_page/garmin_sync_cn_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down Expand Up @@ -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
Expand All @@ -65,7 +57,7 @@
download_new_activities(
secret_string_cn,
auth_domain,
synced_activity,
downloaded_activity,
is_only_running,
folder,
"fit",
Expand Down Expand Up @@ -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")
Expand Down
17 changes: 0 additions & 17 deletions run_page/synced_data_file_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 []

0 comments on commit afe2b25

Please sign in to comment.