-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ab3d655
Showing
7 changed files
with
487 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2.3.4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.17' | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
env: | ||
- GO111MODULE=on | ||
before: | ||
hooks: | ||
- go mod tidy | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
- GO111MODULE=on | ||
goos: | ||
- linux | ||
- darwin | ||
- windows | ||
goarch: | ||
- '386' | ||
- amd64 | ||
- arm | ||
- arm64 | ||
goarm: | ||
- '7' | ||
ignore: | ||
- goos: darwin | ||
goarch: arm | ||
- goos: darwin | ||
goarch: '386' | ||
- goos: windows | ||
goarch: arm64 | ||
mod_timestamp: '{{ .CommitTimestamp }}' | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- -s -w | ||
|
||
checksum: | ||
name_template: '{{ .ProjectName }}_checksums.txt' | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
- fix typo | ||
- Merge pull request | ||
- Merge branch | ||
- Merge remote-tracking | ||
- go mod tidy | ||
|
||
archives: | ||
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' | ||
format_overrides: | ||
- goos: windows | ||
format: zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
go-cqhttp leveldb v3 迁移工具 | ||
=============================== | ||
|
||
## 安装 | ||
|
||
你可以下载 [已经编译好的二进制文件](https://github.com/RomiChan/gocq-leveldb-migrate/releases). | ||
|
||
从源码安装: | ||
```bash | ||
$ go install github.com/RomiChan/gocq-leveldb-migrate@latest | ||
``` | ||
|
||
## 使用方法 | ||
|
||
```bash | ||
./gocq-leveldb-migrate -from xxx -to yyy | ||
``` | ||
默认值: | ||
* from: `data/leveldb-v2` | ||
* to: `data/leveldb-v3` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package cmd | ||
|
||
import ( | ||
"bytes" | ||
"encoding/gob" | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/Mrs4s/go-cqhttp/db" | ||
"github.com/Mrs4s/go-cqhttp/global" | ||
"github.com/pkg/errors" | ||
"github.com/syndtr/goleveldb/leveldb" | ||
) | ||
|
||
func handle(err error) { | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func Main() { | ||
v2 := flag.String("from", "data/leveldb-v2", "leveldb v2 path") | ||
v3 := flag.String("to", "data/leveldb-v3", "leveldb v3 path") | ||
flag.Parse() | ||
if flag.Arg(0) == "help" { | ||
flag.Usage() | ||
return | ||
} | ||
gob.Register(db.StoredMessageAttribute{}) // register gob types | ||
gob.Register(db.StoredGuildMessageAttribute{}) | ||
gob.Register(db.QuotedInfo{}) | ||
gob.Register(global.MSG{}) | ||
gob.Register(db.StoredGroupMessage{}) | ||
gob.Register(db.StoredPrivateMessage{}) | ||
gob.Register(db.StoredGuildChannelMessage{}) | ||
|
||
v2db, err := leveldb.OpenFile(*v2, nil) | ||
handle(err) | ||
defer v2db.Close() | ||
{ | ||
v3db, err := leveldb.OpenFile(*v3, nil) | ||
handle(err) | ||
_ = v3db.Close() | ||
} | ||
v3db, err := leveldb.OpenFile(*v3, nil) | ||
handle(err) | ||
|
||
iter := v2db.NewIterator(nil, nil) | ||
var errs []error | ||
for iter.Next() { | ||
key := iter.Key() | ||
value := iter.Value() | ||
if len(value) == 0 { | ||
continue | ||
} | ||
writer := newWriter() | ||
data := value[1:] | ||
writer.uvarint(uint64(value[0])) | ||
switch value[0] { | ||
case group: | ||
x := &db.StoredGroupMessage{} | ||
if err = gob.NewDecoder(bytes.NewReader(data)).Decode(x); err != nil { | ||
errs = append(errs, errors.Wrap(err, "decode group message failed")) | ||
continue | ||
} | ||
writer.writeStoredGroupMessage(x) | ||
case private: | ||
x := &db.StoredPrivateMessage{} | ||
if err = gob.NewDecoder(bytes.NewReader(data)).Decode(x); err != nil { | ||
errs = append(errs, errors.Wrap(err, "decode private message failed")) | ||
continue | ||
} | ||
writer.writeStoredPrivateMessage(x) | ||
case guildChannel: | ||
x := &db.StoredGuildChannelMessage{} | ||
if err = gob.NewDecoder(bytes.NewReader(data)).Decode(x); err != nil { | ||
errs = append(errs, errors.Wrap(err, "decode guild channel message failed")) | ||
continue | ||
} | ||
writer.writeStoredGuildChannelMessage(x) | ||
} | ||
err := v3db.Put(key, writer.bytes(), nil) | ||
if err != nil { | ||
errs = append(errs, errors.Wrap(err, "put to v3 failed")) | ||
} | ||
} | ||
iter.Release() | ||
if len(errs) > 0 { | ||
for _, err := range errs { | ||
fmt.Printf("%v\n", err) | ||
} | ||
} | ||
tr, err := v3db.OpenTransaction() | ||
handle(err) | ||
handle(tr.Commit()) | ||
handle(v3db.Close()) | ||
} |
Oops, something went wrong.