HelloZeroNet / HelloZeroNet/ZeroNet

Site checkpoints

Ouverte
#1,053 0 commentaires 1 réaction 0 personnes assignées Voir sur GitHub
enhancement hard
Langage dominant
JavaScript
Étoiles
18.8k
Forks
2.3k
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Start by reviewing the sqlite database json table and the checkpoint example at data/users/checkpoint-2017-07-27.json.zip, then compare the alternatives involving dbschema.json and cpschema.json. The TODO list identifies sample files, parsing and updating tests, and checkpoint generation as the completion areas.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript, sqlite
Domaine
backend, database
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.