HelloZeroNet / HelloZeroNet/ZeroNet

Site checkpoints

未关闭
#1,053 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
enhancement hard
主要语言
JavaScript
星标
18.8k
派生
2.3k
PR 合并指标
30 天内没有已合并 PR

描述

Move older site data to a separate checkpoint file to reduce site size, number of files and speed up initial download time.

## Example
Checkpoint file: `data/users/checkpoint-2017-07-27.json.zip`

```
{
"112GGMvUJbBTCtQu8UUSYpo8UjLdo1B73n/content-2017-07-27.json": {
"cert_auth_type": "web",
"cert_user_id": "qu363c@zeroid.bit"
},
"112GGMvUJbBTCtQu8UUSYpo8UjLdo1B73n/data-2017-07-27.json": {
"comment": {
"3_1CoVAt2jBzV4Na6nX3VG1JSfjS8fwse1Z9": [
{
"comment_id": 1,
"body": "This is great!",
"added": 1469117689
}
]
}
}
```

When the `data/users/checkpoint-2017-07-27.json.zip` file downloaded (automatically or manually triggered if optional file) the DB layer acts as if it just received `112GGMvUJbBTCtQu8UUSYpo8UjLdo1B73n/content-2017-07-27.json` and `112GGMvUJbBTCtQu8UUSYpo8UjLdo1B73n/data-2017-07-27.json` files with the given content.

## Problem 1: Know which data is archived.
When a new update comes for a file the db layer drops the old entries and insert the new ones. So we has to know which entries belongs to checkpoint file and which ones are stored in user's data.json.

### Solution A: Change the filename
Archive `112GGMvUJbBTCtQu8UUSYpo8UjLdo1B73n/data.json` file as `112GGMvUJbBTCtQu8UUSYpo8UjLdo1B73n/data-2017-07-27.json`

Pros:
- Does not require changes in site's sqlite database file json table.
Cons:
- Changes in dbschema.json and site's sql queries may required.

### Solution B
Add a new `checkpoint` col to the site's sqlite database json table that stores if the data comes from a checkpoint.

```
json_id directory inner_path checkpoint
1 12uZs7vLvb1b3LdmR3RyYvoCkEazYn162W content.json
2 12uZs7vLvb1b3LdmR3RyYvoCkEazYn162W data.json
3 12uZs7vLvb1b3LdmR3RyYvoCkEazYn162W data.json 2017-07-27
```

So when the update comes in for data.json it will only delete the entries with json_id 2.

Pros:
- Probably more compatibility with current site's data structure
Cons:
- Requires re-create site's json table by reloading all data file.

## TODO
- [ ] Sample files
- [ ] Test parsing
- [ ] Test updating
- [ ] cpschema.json example
- [ ] Generate checkpoint based on cpschema.json

贡献指南

这个仓库没有索引到贡献指南

调研方向

首先检查 sqlite 数据库 JSON 表和 data/users/checkpoint-2017-07-27.json.zip 中的 checkpoint 示例,然后比较涉及 dbschema.json 和 cpschema.json 的替代方案。TODO 列表将示例文件、解析和更新测试以及 checkpoint 生成列为需要完成的部分。

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

评估

技术栈
javascript, sqlite
领域
backend, database
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

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