Skip to content

Commit 7eff9f3

Browse files
authored
filecopy update (#208)
1 parent cd8ddae commit 7eff9f3

File tree

5 files changed

+759
-501
lines changed

5 files changed

+759
-501
lines changed

.goreleaser.yaml

Lines changed: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -90,48 +90,11 @@ release:
9090
mode: replace
9191

9292
# Docker 镜像配置
93+
# FIXME: 等待 goreleaser 2.12 更新后使用 dockers_v2
9394
dockers:
94-
# GitHub Container Registry
9595
- image_templates:
9696
- "ghcr.io/sjzar/chatlog:{{ .Tag }}-amd64"
97-
- "ghcr.io/sjzar/chatlog:latest-amd64"
98-
dockerfile: Dockerfile
99-
use: buildx
100-
goos: linux
101-
goarch: amd64
102-
build_flag_templates:
103-
- "--platform=linux/amd64"
104-
- "--label=org.opencontainers.image.title={{.ProjectName}}"
105-
- "--label=org.opencontainers.image.description=chat log tool, easily use your own chat data."
106-
- "--label=org.opencontainers.image.url=https://github.com/sjzar/chatlog"
107-
- "--label=org.opencontainers.image.source=https://github.com/sjzar/chatlog"
108-
- "--label=org.opencontainers.image.version={{.Version}}"
109-
- "--label=org.opencontainers.image.created={{.Date}}"
110-
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
111-
- "--label=org.opencontainers.image.licenses=Apache-2.0"
112-
113-
- image_templates:
114-
- "ghcr.io/sjzar/chatlog:{{ .Tag }}-arm64"
115-
- "ghcr.io/sjzar/chatlog:latest-arm64"
116-
dockerfile: Dockerfile
117-
use: buildx
118-
goos: linux
119-
goarch: arm64
120-
build_flag_templates:
121-
- "--platform=linux/arm64"
122-
- "--label=org.opencontainers.image.title={{.ProjectName}}"
123-
- "--label=org.opencontainers.image.description=chat log tool, easily use your own chat data."
124-
- "--label=org.opencontainers.image.url=https://github.com/sjzar/chatlog"
125-
- "--label=org.opencontainers.image.source=https://github.com/sjzar/chatlog"
126-
- "--label=org.opencontainers.image.version={{.Version}}"
127-
- "--label=org.opencontainers.image.created={{.Date}}"
128-
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
129-
- "--label=org.opencontainers.image.licenses=Apache-2.0"
130-
131-
# Docker Hub
132-
- image_templates:
13397
- "sjzar/chatlog:{{ .Tag }}-amd64"
134-
- "sjzar/chatlog:latest-amd64"
13598
dockerfile: Dockerfile
13699
use: buildx
137100
goos: linux
@@ -148,8 +111,8 @@ dockers:
148111
- "--label=org.opencontainers.image.licenses=Apache-2.0"
149112

150113
- image_templates:
114+
- "ghcr.io/sjzar/chatlog:{{ .Tag }}-arm64"
151115
- "sjzar/chatlog:{{ .Tag }}-arm64"
152-
- "sjzar/chatlog:latest-arm64"
153116
dockerfile: Dockerfile
154117
use: buildx
155118
goos: linux
@@ -172,17 +135,21 @@ docker_manifests:
172135
image_templates:
173136
- "ghcr.io/sjzar/chatlog:{{ .Tag }}-amd64"
174137
- "ghcr.io/sjzar/chatlog:{{ .Tag }}-arm64"
175-
- name_template: "ghcr.io/sjzar/chatlog:latest"
176-
image_templates:
177-
- "ghcr.io/sjzar/chatlog:latest-amd64"
178-
- "ghcr.io/sjzar/chatlog:latest-arm64"
179-
138+
180139
# Docker Hub manifests
181140
- name_template: "sjzar/chatlog:{{ .Tag }}"
182141
image_templates:
183142
- "sjzar/chatlog:{{ .Tag }}-amd64"
184143
- "sjzar/chatlog:{{ .Tag }}-arm64"
185-
- name_template: "sjzar/chatlog:latest"
144+
145+
# GitHub Container Registry latest
146+
- name_template: "{{ if not .Prerelease }}ghcr.io/sjzar/chatlog:latest{{ end }}"
186147
image_templates:
187-
- "sjzar/chatlog:latest-amd64"
188-
- "sjzar/chatlog:latest-arm64"
148+
- "ghcr.io/sjzar/chatlog:{{ .Tag }}-amd64"
149+
- "ghcr.io/sjzar/chatlog:{{ .Tag }}-arm64"
150+
151+
# Docker Hub latest
152+
- name_template: "{{ if not .Prerelease }}sjzar/chatlog:latest{{ end }}"
153+
image_templates:
154+
- "sjzar/chatlog:{{ .Tag }}-amd64"
155+
- "sjzar/chatlog:{{ .Tag }}-arm64"

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.24.0
44

55
require (
66
github.com/Eyevinn/mp4ff v0.49.0
7+
github.com/cespare/xxhash v1.1.0
78
github.com/fsnotify/fsnotify v1.9.0
89
github.com/gdamore/tcell/v2 v2.8.1
910
github.com/gin-gonic/gin v1.10.1

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
github.com/Eyevinn/mp4ff v0.49.0 h1:00eRg5/KwcLGWUbv+hlifldf74qg46G1IxoWXHrgDvw=
22
github.com/Eyevinn/mp4ff v0.49.0/go.mod h1:hJNUUqOBryLAzUW9wpCJyw2HaI+TCd2rUPhafoS5lgg=
3+
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
4+
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
35
github.com/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ=
46
github.com/bytedance/sonic v1.14.0/go.mod h1:WoEbx8WTcFJfzCe0hbmyTGrfjt8PzNEBdxlNUO24NhA=
57
github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=
68
github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
9+
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
10+
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
711
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
812
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
913
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
@@ -121,6 +125,8 @@ github.com/sjzar/go-silk v0.0.1 h1:cXD9dsIZti3n+g0Fd3IUvLH9A7tyL4jvUsHEyhff21s=
121125
github.com/sjzar/go-silk v0.0.1/go.mod h1:IXVcHEXKiU9j3ZtHEiGS37OFKkex9pdAhZVcFzAIOlM=
122126
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw=
123127
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U=
128+
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=
129+
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
124130
github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA=
125131
github.com/spf13/afero v1.14.0/go.mod h1:acJQ8t0ohCGuMN3O+Pv0V0hgMxNYDlvdk+VTfyZmbYo=
126132
github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE=

internal/wechatdb/datasource/dbm/dbm.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dbm
22

33
import (
44
"database/sql"
5+
"path/filepath"
56
"runtime"
67
"sync"
78
"time"
@@ -17,6 +18,7 @@ import (
1718

1819
type DBManager struct {
1920
path string
21+
id string
2022
fm *filemonitor.FileMonitor
2123
fgs map[string]*filemonitor.FileGroup
2224
dbs map[string]*sql.DB
@@ -27,6 +29,7 @@ type DBManager struct {
2729
func NewDBManager(path string) *DBManager {
2830
return &DBManager{
2931
path: path,
32+
id: filepath.Base(path),
3033
fm: filemonitor.NewFileMonitor(),
3134
fgs: make(map[string]*filemonitor.FileGroup),
3235
dbs: make(map[string]*sql.DB),
@@ -118,7 +121,7 @@ func (d *DBManager) OpenDB(path string) (*sql.DB, error) {
118121
var err error
119122
tempPath := path
120123
if runtime.GOOS == "windows" {
121-
tempPath, err = filecopy.GetTempCopy(path)
124+
tempPath, err = filecopy.GetTempCopy(d.id, path)
122125
if err != nil {
123126
log.Err(err).Msgf("获取临时拷贝文件 %s 失败", path)
124127
return nil, err

0 commit comments

Comments
 (0)