Compare commits

2 Commits

Author SHA1 Message Date
idk
7bd7ee517d boltdb go.mod updates 2021-12-13 14:00:31 -05:00
idk
c89cda8d62 start switching to boltdb 2021-12-13 13:17:12 -05:00
7 changed files with 46 additions and 25 deletions

View File

@@ -6,6 +6,8 @@ VERSION=0.0.036
LAST_VERSION=0.0.035
USER_GH=eyedeekay
ARG=-v -tags netgo -ldflags '-w -extldflags "-static"'
releases: $(GOPATH)/src/i2pgit.org/idk/railroad clean linux-releases windows-releases copy sums
linux-releases: linux linzip
@@ -13,13 +15,13 @@ linux-releases: linux linzip
windows-releases: windows winzip
binary:
go build -o railroad-$(GOOS)
go build $(ARG) -o railroad-$(GOOS)
linux:
GOOS=linux make binary
rb:
/usr/lib/go-1.15/bin/go build -ldflags "-s -w" -o $(REPO_NAME)-$(GOOS)
/usr/lib/go-1.15/bin/go build $(ARG) -ldflags "-s -w" -o $(REPO_NAME)-$(GOOS)
docker:
docker build -t $(USER_GH)/$(REPO_NAME):$(VERSION) .
@@ -37,6 +39,7 @@ windows: railroad-windows.exe
railroad-windows.exe:
xgo --targets=windows/amd64 . && mv railroad-windows-4.0-amd64.exe railroad-windows.exe
cp railroad-windows.exe railroad-windows
wget -O WebView2Loader.dll https://github.com/webview/webview/raw/master/dll/x64/WebView2Loader.dll
wget -O webview.dll https://github.com/webview/webview/raw/master/dll/x64/webview.dll
make nsis
@@ -47,17 +50,17 @@ winzip: clean
-x="./.git/*" -r ../railroad-$(VERSION).zip .
copy:
cp -v ../railroad-$(VERSION).tar.gz .
cp -v ../railroad-$(VERSION).zip .
cp -v ../i2p-railroad_$(VERSION)-1_amd64.deb .
cp -v ../railroad-installer.exe railroad-installer-$(VERSION).exe
#cp -v ./railroad-$(VERSION).tar.gz ..
#cp -v ./railroad-$(VERSION).zip ..
#cp -v ./i2p-railroad_$(VERSION)-1_amd64.deb ..
#cp -v ./railroad-installer.exe railroad-installer-$(VERSION).exe
$(GOPATH)/src/i2pgit.org/idk/railroad:
mkdir -p $(GOPATH)/src/i2pgit.org/idk/railroad
git clone https://i2pgit.org/idk/railroad $(GOPATH)/src/i2pgit.org/idk/railroad
clean:
rm -rf *.private railroad railroad-* *.public.txt *.tar.gz *.deb *.zip *.exe plugin-config/WebView2Loader.dll plugin-config/webview.dll I2P-Zero
rm -rf *.private plugin railroad railroad-* *.public.txt *.tar.gz *.deb *.zip *.exe plugin-config/WebView2Loader.dll plugin-config/webview.dll I2P-Zero
sums:
sha256sum *.tar.gz *.zip *.deb *-installer.exe
@@ -131,14 +134,14 @@ zip:
zip railroad.zip -r railroad
osx:
go build -o railroad-$(GOOS)
go build -tags osxalt -o railroad-$(GOOS)-ui
go build $(ARG) -o railroad-$(GOOS)
go build $(ARG) -tags osxalt -o railroad-$(GOOS)-ui
macapp:
mkdir -p railroad.app/Contents/MacOS/content
cp -r content/* railroad.app/Contents/MacOS/content/
go build -o railroad-$(GOOS).app/Contents/MacOS/railroad
go build -tags osxalt -o railroad-$(GOOS).app/Contents/MacOS/railroad-ui
go build $(ARG) -o railroad-$(GOOS).app/Contents/MacOS/railroad
go build $(ARG) -tags osxalt -o railroad-$(GOOS).app/Contents/MacOS/railroad-ui
fmt:
find . -name '*.go' -exec gofmt -w -s {} \;
@@ -160,12 +163,12 @@ upload-plugins:
release: clean linzip winzip releases plugins release-upload
release-upload: check
release-upload: #check
cat desc changelog | grep -B 10 "$(LAST_VERSION)" | gothub release -p -u $(USER_GH) -r $(REPO_NAME) -t $(VERSION) -n $(VERSION) -d -; true
gothub upload -R -u $(USER_GH) -r "$(REPO_NAME)" -t $(VERSION) -l "$(sumzip)" -n "railroad-$(VERSION).zip" -f "../railroad-$(VERSION).zip"
gothub upload -R -u $(USER_GH) -r "$(REPO_NAME)" -t $(VERSION) -l "$(sumexe)" -n "railroad-installer-$(VERSION).exe" -f "../railroad-installer-$(VERSION).exe"
gothub upload -R -u $(USER_GH) -r "$(REPO_NAME)" -t $(VERSION) -l "$(sumtar)" -n "railroad-$(VERSION).tar.gz" -f "../railroad-$(VERSION).tar.gz"
gothub upload -R -u $(USER_GH) -r "$(REPO_NAME)" -t $(VERSION) -l "$(sumdeb)" -n "i2p-railroad_$(VERSION)-1_amd64.deb" -f "../i2p-railroad_$(VERSION)-1_amd64.deb"
# gothub upload -R -u $(USER_GH) -r "$(REPO_NAME)" -t $(VERSION) -l "$(sumzip)" -n "railroad-$(VERSION).zip" -f "../railroad-$(VERSION).zip"
# gothub upload -R -u $(USER_GH) -r "$(REPO_NAME)" -t $(VERSION) -l "$(sumexe)" -n "railroad-installer-$(VERSION).exe" -f "../railroad-installer-$(VERSION).exe"
# gothub upload -R -u $(USER_GH) -r "$(REPO_NAME)" -t $(VERSION) -l "$(sumtar)" -n "railroad-$(VERSION).tar.gz" -f "../railroad-$(VERSION).tar.gz"
# gothub upload -R -u $(USER_GH) -r "$(REPO_NAME)" -t $(VERSION) -l "$(sumdeb)" -n "i2p-railroad_$(VERSION)-1_amd64.deb" -f "../i2p-railroad_$(VERSION)-1_amd64.deb"
gothub upload -R -u $(USER_GH) -r "$(REPO_NAME)" -t $(VERSION) -l "$(sumrrlinux)" -n "$(REPO_NAME)-linux.su3" -f "../railroad-linux.su3"
gothub upload -R -u $(USER_GH) -r "$(REPO_NAME)" -t $(VERSION) -l "$(sumrrwindows)" -n "$(REPO_NAME)-windows.su3" -f "../railroad-windows.su3"
# gothub upload -R -u $(USER_GH) -r "$(REPO_NAME)" -t $(VERSION) -n "" -f ""
@@ -206,7 +209,7 @@ plugin-linux:
GOOS=linux make plugin-pkg
plugin-windows:
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ make binary
make windows
GOOS=windows make plugin-pkg
plugin-pkg:

View File

@@ -4,7 +4,7 @@ const stmtDeletePostTagsByPostId = "DELETE FROM posts_tags WHERE post_id = ?"
const stmtDeletePostById = "DELETE FROM posts WHERE id = ?"
func DeletePostTagsForPostId(post_id int64) error {
writeDB, err := readDB.Begin()
writeDB, err := readDB.Begin(true)
if err != nil {
writeDB.Rollback()
return err
@@ -18,12 +18,16 @@ func DeletePostTagsForPostId(post_id int64) error {
}
func DeletePostById(id int64) error {
writeDB, err := readDB.Begin()
writeDB, err := readDB.Begin(true)
if err != nil {
writeDB.Rollback()
return err
}
_, err = writeDB.Exec(stmtDeletePostById, id)
//err = writeDB.Update(func(tx *bolt.Tx) error {
// b := tx.Bucket([]byte(BucketSharedVar))
// return b.Delete([]byte(n))
//})
if err != nil {
writeDB.Rollback()
return err

View File

@@ -1,10 +1,11 @@
package database
import (
"database/sql"
"time"
_ "github.com/mattn/go-sqlite3"
"github.com/satori/go.uuid"
//_ "github.com/mattn/go-sqlite3"
"github.com/boltdb/bolt"
uuid "github.com/satori/go.uuid"
"i2pgit.org/idk/railroad/database/migration"
"i2pgit.org/idk/railroad/date"
"i2pgit.org/idk/railroad/filenames"
@@ -13,7 +14,7 @@ import (
)
// Handler for read access
var readDB *sql.DB
var readDB *bolt.DB
var stmtInitialization = `CREATE TABLE IF NOT EXISTS
posts (
@@ -134,7 +135,10 @@ func Initialize() error {
}
// Open or create database file
var err error
readDB, err = sql.Open("sqlite3", filenames.DatabaseFilename)
readDB, err = bolt.Open(filenames.DatabaseFilename, 0644,
&bolt.Options{
Timeout: 1 * time.Second,
})
if err != nil {
return err
}

3
go.mod
View File

@@ -5,6 +5,7 @@ go 1.16
require (
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/atotto/clipboard v0.1.4
github.com/boltdb/bolt v1.3.1
github.com/dimfeld/httptreemux v5.0.1+incompatible
github.com/eyedeekay/checki2cp v0.0.21
github.com/eyedeekay/sam3 v0.32.33-0.20210313224934-b9e4186119b8
@@ -19,7 +20,7 @@ require (
github.com/kabukky/httpscerts v0.0.0-20150320125433-617593d7dcb3
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
github.com/klauspost/compress v1.13.6 // indirect
github.com/mattn/go-sqlite3 v1.14.9
github.com/mattn/go-sqlite3 v1.14.9 // indirect
github.com/mholt/archiver/v3 v3.5.1 // indirect
github.com/nwaples/rardecode v1.1.2 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect

2
go.sum
View File

@@ -7,6 +7,8 @@ github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/bradfitz/gomemcache v0.0.0-20170208213004-1952afaa557d/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -225,6 +225,13 @@ func main() {
}
}
for {
if checksam.CheckSAMAvailable("127.0.0.1:7656") {
break
}
time.Sleep(time.Second * 10)
}
// Setup
var err error
err = os.Chdir(flags.CustomPath)