Skip to content

Commit

Permalink
implementation of sync/makesync (#149)
Browse files Browse the repository at this point in the history
* syncfile is binary to improve serialization/deserialization speed
* port to xxhash
* add multi-range download step
* remove overfetching, default to 20kb chunks
  • Loading branch information
bdon authored Mar 8, 2024
1 parent 8f41de2 commit e6b8514
Show file tree
Hide file tree
Showing 2 changed files with 253 additions and 104 deletions.
11 changes: 6 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ var cli struct {

Makesync struct {
Input string `arg:"" type:"existingfile"`
BlockSizeKb int `default:"1000" help:"The approximate block size, in kilobytes. 0 means 1 tile = 1 block."`
HashFunction string `default:"fnv1a" help:"The hash function."`
BlockSizeKb int `default:"20" help:"The approximate block size, in kilobytes. 0 means 1 tile = 1 block."`
HashFunction string `default:"xxh64" help:"The hash function."`
Checksum string `help:"Store a checksum in the syncfile."`
} `cmd:"" hidden:""`

Sync struct {
Existing string `arg:"" type:"existingfile"`
Syncfile string `arg:"" type:"existingfile"`
New string `arg:"" help:"Local or remote archive, with .sync sidecar file."`
DryRun bool `help:"Calculate new parts to download, but don't download them."`
} `cmd:"" hidden:""`

Serve struct {
Expand Down Expand Up @@ -210,8 +211,8 @@ func main() {
if err != nil {
logger.Fatalf("Failed to makesync archive, %v", err)
}
case "sync <existing> <syncfile>":
err := pmtiles.Sync(logger, cli.Sync.Existing, cli.Sync.Syncfile)
case "sync <existing> <new>":
err := pmtiles.Sync(logger, cli.Sync.Existing, cli.Sync.New, cli.Sync.DryRun)
if err != nil {
logger.Fatalf("Failed to sync archive, %v", err)
}
Expand Down
Loading

0 comments on commit e6b8514

Please sign in to comment.