Skip to content

Commit

Permalink
Fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncruces committed Jan 7, 2025
1 parent c0a56da commit e73483a
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 59 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/cross.sh

This file was deleted.

16 changes: 0 additions & 16 deletions .github/workflows/cross.yml

This file was deleted.

15 changes: 10 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ name: Test

on:
push:
branches: [ "main" ]
branches: [ 'main' ]
paths:
- '**.go'
- '**.mod'
- '**.wasm'
pull_request:
branches: [ "main" ]
branches: [ 'main' ]
paths:
- '**.go'
- '**.mod'
Expand Down Expand Up @@ -159,9 +159,9 @@ jobs:
copyback: false
run: . ./test.sh

test-wasm:
test-wasip1:
runs-on: ubuntu-latest
# needs: test
needs: test

steps:
- uses: bytecodealliance/actions/wasmtime/setup@v1
Expand All @@ -173,7 +173,12 @@ jobs:
run: echo "$(go env GOROOT)/misc/wasm" >> "$GITHUB_PATH"

- name: Test wasmtime
run: GOARCH=wasm GOOS=wasip1 go test -v -short -tags sqlite3_dotlk ./...
env:
GOOS: wasip1
GOARCH: wasm
GOWASIRUNTIME: wasmtime
GOWASIRUNTIMEARGS: '--env CI=true'
run: go test -v -short -tags sqlite3_dotlk -skip Example ./...

test-qemu:
runs-on: ubuntu-latest
Expand Down
10 changes: 8 additions & 2 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math"
"math/rand"
"net/url"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -375,8 +376,13 @@ func (c *Conn) checkInterrupt(handle uint32) {
}

func progressCallback(ctx context.Context, mod api.Module, _ uint32) (interrupt uint32) {
if c, ok := ctx.Value(connKey{}).(*Conn); ok && c.interrupt.Err() != nil {
interrupt = 1
if c, ok := ctx.Value(connKey{}).(*Conn); ok {
if c.interrupt.Done() != nil {
runtime.Gosched()
}
if c.interrupt.Err() != nil {
interrupt = 1
}
}
return interrupt
}
Expand Down
3 changes: 0 additions & 3 deletions tests/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ func TestConn_SetInterrupt(t *testing.T) {
t.Fatal(err)
}

db.SetInterrupt(context.Background())

stmt, _, err := db.Prepare(`
WITH RECURSIVE
fibonacci (curr, next)
Expand All @@ -148,7 +146,6 @@ func TestConn_SetInterrupt(t *testing.T) {
}
defer stmt.Close()

db.SetInterrupt(ctx)
go func() {
time.Sleep(time.Millisecond)
cancel()
Expand Down
11 changes: 5 additions & 6 deletions vfs/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io/fs"
"os"
"path/filepath"
"runtime"
"syscall"

"github.com/ncruces/go-sqlite3/util/osutil"
Expand Down Expand Up @@ -41,7 +40,7 @@ func (vfsOS) Delete(path string, syncDir bool) error {
if err != nil {
return err
}
if runtime.GOOS != "windows" && syncDir {
if canSyncDirs && syncDir {
f, err := os.Open(filepath.Dir(path))
if err != nil {
return _OK
Expand Down Expand Up @@ -120,9 +119,9 @@ func (vfsOS) OpenFilename(name *Filename, flags OpenFlag) (File, OpenFlag, error
File: f,
psow: true,
readOnly: flags&OPEN_READONLY != 0,
syncDir: runtime.GOOS != "windows" &&
flags&(OPEN_CREATE) != 0 &&
flags&(OPEN_MAIN_JOURNAL|OPEN_SUPER_JOURNAL|OPEN_WAL) != 0,
syncDir: canSyncDirs &&
flags&(OPEN_MAIN_JOURNAL|OPEN_SUPER_JOURNAL|OPEN_WAL) != 0 &&
flags&(OPEN_CREATE) != 0,
shm: NewSharedMemory(name.String()+"-shm", flags),
}
return &file, flags, nil
Expand Down Expand Up @@ -163,7 +162,7 @@ func (f *vfsFile) Sync(flags SyncFlag) error {
if err != nil {
return err
}
if runtime.GOOS != "windows" && f.syncDir {
if canSyncDirs && f.syncDir {
f.syncDir = false
d, err := os.Open(filepath.Dir(f.File.Name()))
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion vfs/os_std.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import (
"os"
)

const _O_NOFOLLOW = 0
const (
_O_NOFOLLOW = 0
canSyncDirs = false
)

func osAccess(path string, flags AccessFlag) error {
fi, err := os.Stat(path)
Expand Down
5 changes: 4 additions & 1 deletion vfs/os_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import (
"golang.org/x/sys/unix"
)

const _O_NOFOLLOW = unix.O_NOFOLLOW
const (
_O_NOFOLLOW = unix.O_NOFOLLOW
canSyncDirs = true
)

func osAccess(path string, flags AccessFlag) error {
var access uint32 // unix.F_OK
Expand Down
5 changes: 5 additions & 0 deletions vfs/vfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ func Test_vfsAccess(t *testing.T) {
t.Error("can't access file")
}

if fi, err := os.Stat(file); err != nil {
t.Fatal(err)
} else if fi.Mode().Perm()&0700 != syscall.S_IRUSR {
t.Skip("skipping due to permissions")
}
if usr, err := user.Current(); err == nil && usr.Uid == "0" {
t.Skip("skipping as root")
}
Expand Down

0 comments on commit e73483a

Please sign in to comment.