Companion/extra-waypoint GPX imported without matching cache silently produces zero results, no warning

未关闭 适合新手
#648 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
python
领域
data

调研方向

从 src/opensak/importer/__init__.py 开始:阅读 _insert_extra_wpts() 和 if cache_id is None: continue 分支,然后找到 import_gpx() 中构建 ImportResult 的位置。使用 tests/data.py 中的 SAMPLE_WPTS_GPX,在空数据库中复现,并确认结果没有警告。当该导入向 result.warnings 添加一条警告,说明有多少个航点没有匹配的缓存,并且导入器测试中有一个测试对此进行检查时,任务完成。

由索引模型根据 Issue 内容生成。

描述

area: import improvement
Current State
Background

import_gpx() handles two kinds of GPX <wpt> entries: full geocache
records, and "extra" (child/companion) waypoints belonging to a parent cache
(type="Waypoint|..."). The latter are collected into extra_wpts during
parsing and linked to their parent via _insert_extra_wpts().

If a GPX file contains only extra waypoints — e.g. a companion
xxx-wpts.gpx from a Pocket Query with "Include Additional Waypoints", or
any file imported when its parent cache doesn't yet exist in the active
database — _insert_extra_wpts() silently drops them:

for suffix, wps in wpts_by_suffix.items():
    cache_id = suffix_to_cache_id.get(suffix)
    if cache_id is None:
        continue          # <-- silently discarded, no warning

get_import_type() (utils/utils.py) classifies purely by file extension, so
a companion-only GPX is indistinguishable from a normal cache GPX until
parsing — the user has no way to know which kind of file they picked.

Proposed Improvement
Reproduced

Imported a companion-only GPX (SAMPLE_WPTS_GPX from tests/data.py) into an
empty database:

created=0 updated=0 skipped=0 waypoints=0 errors=[]

No exception, no entry in result.errors, no entry in result.warnings
(the field exists and is already used by the LOC importer, just not here).
The import dialog shows a plain ✅ with all-zero counts — nothing to alert
the user that the file only contained orphaned child waypoints.

Expected Benefits
Expected behavior

When extra_wpts contains waypoints whose suffix has no matching cache,
append a message to result.warnings, e.g.:

"N waypoints found but no matching cache exists in the database.
 Import the main cache GPX first."

so the existing warnings-display path in the import dialog surfaces it
instead of a silent all-zero success.

Where

src/opensak/importer/__init__.py, _insert_extra_wpts() (the
if cache_id is None: continue branch) and the caller in import_gpx()
where ImportResult is assembled.

主要语言
Python
星标
37
派生
17
平均合并
21 小时 5 分钟
30 天内合并 PR
131

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

OpenSAK-Org/OpenSAK 的其他 Issue

查看 OpenSAK-Org/OpenSAK 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。