19 lines
420 B
Go
19 lines
420 B
Go
package sqliteutil
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// ChmodFiles applies mode to a SQLite database and existing WAL/SHM sidecars.
|
|
func ChmodFiles(path string, mode os.FileMode) error {
|
|
for _, suffix := range []string{"", "-wal", "-shm"} {
|
|
p := path + suffix
|
|
if err := os.Chmod(p, mode); err != nil && !os.IsNotExist(err) {
|
|
return fmt.Errorf("chmod %s: %w", filepath.Base(p), err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|