Merge branch 'fix/httpvfs-chunked-length'

# Conflicts:
#	web/src/lib/db-probe.test.js
#	web/src/lib/sqlite.svelte.js
This commit is contained in:
tiennm99 committed 2026-10-03 11:59:22 +07:00
commit d4f106f488
16 files changed
+471 -132

No files matched your search

+12 -4
View File
@@ -35,10 +35,18 @@ const driverName = "sqlite"
// even if the row count somehow passed.
const minSizeRatio = 0.9
// Extension is the published suffix. Not ".db": keeping that name free lets
// the site assembly treat any stray .db or SQLite journal in the output as the
// leftover it is.
const Extension = ".sqlite3"
// Extension is the published suffix. The trailing 0 is a chunk index, not a
// typo: the browser reads the file through sql.js-httpvfs in chunked mode,
// which is the only mode whose config accepts the file's length. That mode
// builds each request's URL as urlPrefix + chunkIndex, and one chunk holds the
// whole database, so the index is always 0 and the prefix is "<id>.sqlite3".
//
// The length has to come from the config because the library otherwise takes
// it from a HEAD request, which GitHub Pages answers with the gzipped size.
//
// Not ".db" either: keeping that name free lets the site assembly treat any
// stray .db or SQLite journal in the output as the leftover it is.
const Extension = ".sqlite30"
// Paths locates the pieces this package needs.
type Paths struct {
@@ -12,9 +12,9 @@ import (
func TestCleanRemovesOnlyDroppedDatasets(t *testing.T) {
dir := t.TempDir()
for _, name := range []string{
"2016.sqlite3", "2017.sqlite3",
"2017-old.sqlite3", // dropped from the registry
"2017-old2.sqlite3", // dropped from the registry
"2016.sqlite30", "2017.sqlite30",
"2017-old.sqlite30", // dropped from the registry
"2017-old2.sqlite30", // dropped from the registry
"2016.db-journal", // interrupted run
} {
if err := os.WriteFile(filepath.Join(dir, name), []byte("x"), 0o644); err != nil {
@@ -38,7 +38,7 @@ func TestCleanRemovesOnlyDroppedDatasets(t *testing.T) {
}
slices.Sort(left)
want := []string{"2016.sqlite3", "2017.sqlite3"}
want := []string{"2016.sqlite30", "2017.sqlite30"}
if !slices.Equal(left, want) {
t.Errorf("left %v, want %v", left, want)
}