mirror of
https://github.com/teest114514/chatlog_alpha.git
synced 2026-04-09 15:52:45 +08:00
Introduces experimental WAL (Write-Ahead Logging) incremental sync for WeChat database decryption, allowing real-time monitoring and incremental updates to the working directory database. Adds UI and config options to enable WAL support and configure auto-decrypt debounce interval. Updates related services, context, and data source logic to support WAL file handling, incremental decryption, and improved process detection. Also improves single-instance process checks and updates documentation for these new features.
62 lines
1.8 KiB
Go
62 lines
1.8 KiB
Go
package datasource
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/fsnotify/fsnotify"
|
|
|
|
"github.com/sjzar/chatlog/internal/errors"
|
|
"github.com/sjzar/chatlog/internal/model"
|
|
v4 "github.com/sjzar/chatlog/internal/wechatdb/datasource/v4"
|
|
)
|
|
|
|
type DataSource interface {
|
|
|
|
// 消息
|
|
GetMessages(ctx context.Context, startTime, endTime time.Time, talker string, sender string, keyword string, limit, offset int) ([]*model.Message, error)
|
|
GetMessage(ctx context.Context, talker string, seq int64) (*model.Message, error)
|
|
|
|
// 联系人
|
|
GetContacts(ctx context.Context, key string, limit, offset int) ([]*model.Contact, error)
|
|
|
|
// 群聊
|
|
GetChatRooms(ctx context.Context, key string, limit, offset int) ([]*model.ChatRoom, error)
|
|
|
|
// 最近会话
|
|
GetSessions(ctx context.Context, key string, limit, offset int) ([]*model.Session, error)
|
|
|
|
// 媒体
|
|
GetMedia(ctx context.Context, _type string, key string) (*model.Media, error)
|
|
|
|
// 朋友圈
|
|
GetSNSTimeline(ctx context.Context, username string, limit, offset int) ([]map[string]interface{}, error)
|
|
GetSNSCount(ctx context.Context, username string) (int, error)
|
|
|
|
// 设置回调函数
|
|
SetCallback(group string, callback func(event fsnotify.Event) error) error
|
|
|
|
// 获取数据库列表
|
|
GetDBs() (map[string][]string, error)
|
|
|
|
// 获取指定数据库的表列表
|
|
GetTables(group, file string) ([]string, error)
|
|
|
|
// 获取指定表的数据
|
|
GetTableData(group, file, table string, limit, offset int, keyword string) ([]map[string]interface{}, error)
|
|
|
|
// 执行 SQL 查询
|
|
ExecuteSQL(group, file, query string) ([]map[string]interface{}, error)
|
|
|
|
Close() error
|
|
}
|
|
|
|
func New(path string, platform string, version int, walEnabled bool) (DataSource, error) {
|
|
switch {
|
|
case platform == "windows" && version == 4:
|
|
return v4.New(path, walEnabled)
|
|
default:
|
|
return nil, errors.PlatformUnsupported(platform, version)
|
|
}
|
|
}
|