From 3d48b882c57ea5f71a0d8a320eaa3fe3586ba768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0irhoe=20Biazhkovi=C4=8D?= Date: Mon, 17 Oct 2022 19:32:41 +0300 Subject: [PATCH] fix pg test and lint warning TODO: update doc and sample config --- storage/pg/storage_test.go | 4 ++-- storage/redis/storage.go | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/storage/pg/storage_test.go b/storage/pg/storage_test.go index d92847a..bab82de 100644 --- a/storage/pg/storage_test.go +++ b/storage/pg/storage_test.go @@ -29,7 +29,7 @@ CREATE INDEX mo_peers_announce_idx ON mo_peers(info_hash, is_seeder, is_v6); DROP TABLE IF EXISTS mo_downloads; CREATE TABLE mo_downloads ( info_hash bytea PRIMARY KEY NOT NULL, - downloads int NOT NULL DEFAULT 0 + downloads int NOT NULL DEFAULT 1 ); DROP TABLE IF EXISTS mo_kv; @@ -62,7 +62,7 @@ var cfg = Config{ }, Downloads: downloadQueryConf{ GetQuery: "SELECT downloads FROM mo_downloads where info_hash=@info_hash", - IncrementQuery: "UPDATE mo_downloads SET downloads = downloads + 1 WHERE info_hash=@info_hash", + IncrementQuery: "INSERT INTO mo_downloads VALUES(@info_hash) ON CONFLICT(info_hash) DO UPDATE SET downloads = mo_downloads.downloads + 1", }, Data: dataQueryConf{ AddQuery: "INSERT INTO mo_kv VALUES(@context, @key, @value) ON CONFLICT (context, name) DO NOTHING", diff --git a/storage/redis/storage.go b/storage/redis/storage.go index 152bdbd..a5e3ff1 100644 --- a/storage/redis/storage.go +++ b/storage/redis/storage.go @@ -228,7 +228,6 @@ func (cfg Config) Connect() (con Connection, err error) { _ = rs.Close() rs = nil } - cfg.Login, cfg.Password = "", "" return Connection{rs}, err }