Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed a bug where incremental uploads failed #734

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 []