From afcb80f913a7fecc89be9edbaf3be46c1b76c965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kris=20N=C3=B3va?= Date: Sat, 13 Feb 2021 13:30:08 -0800 Subject: [PATCH] Fixes 2: Fixing regression for issue 2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kris NĂ³va --- client.go | 8 +++++++ .../storage/albums/album/aqohkx21cwlrrs71.yml | 9 +++++++ .../storage/albums/album/aqohkx21dyhq6xa6.yml | 9 +++++++ .../storage/albums/album/aqohkx21j9rj6w4f.yml | 9 +++++++ .../storage/albums/album/aqohkx22im2tmqpd.yml | 10 ++++++++ .../storage/albums/album/aqohl0w1s0skc6f0.yml | 9 +++++++ .../storage/albums/album/aqohl0w2dwab02xe.yml | 9 +++++++ .../storage/albums/album/aqohl0w2xt57x1cb.yml | 10 ++++++++ .../storage/albums/album/aqohl0wdspiitn0a.yml | 9 +++++++ .../photoprism/storage/cache/sessions.json | 20 ++++++++++++++++ sample-app/photoprism/storage/index.db | Bin 446464 -> 454656 bytes .../2021/02/20210204_031706_5B740007.yml | 6 ++--- test/regression_test.go | 22 ++++++++++++++++++ 13 files changed, 127 insertions(+), 3 deletions(-) create mode 100755 sample-app/photoprism/storage/albums/album/aqohkx21cwlrrs71.yml create mode 100755 sample-app/photoprism/storage/albums/album/aqohkx21dyhq6xa6.yml create mode 100755 sample-app/photoprism/storage/albums/album/aqohkx21j9rj6w4f.yml create mode 100755 sample-app/photoprism/storage/albums/album/aqohkx22im2tmqpd.yml create mode 100755 sample-app/photoprism/storage/albums/album/aqohl0w1s0skc6f0.yml create mode 100755 sample-app/photoprism/storage/albums/album/aqohl0w2dwab02xe.yml create mode 100755 sample-app/photoprism/storage/albums/album/aqohl0w2xt57x1cb.yml create mode 100755 sample-app/photoprism/storage/albums/album/aqohl0wdspiitn0a.yml create mode 100644 test/regression_test.go diff --git a/client.go b/client.go index e9af7c1..cd98268 100644 --- a/client.go +++ b/client.go @@ -23,6 +23,10 @@ const ( // New is used to create a new Client to authenticate with // Photoprism. func New(connectionString string) *Client { + for strings.HasSuffix(connectionString, "/") { + connectionString = connectionString[:len(connectionString)-1] + } + c := &Client{ contentType: APIContentType, connectionString: connectionString, @@ -30,6 +34,10 @@ func New(connectionString string) *Client { return c } +func (c *Client) ConnectionString() string { + return c.connectionString +} + // Client represents a client to a Photoprism application type Client struct { v1client *v1.V1Client diff --git a/sample-app/photoprism/storage/albums/album/aqohkx21cwlrrs71.yml b/sample-app/photoprism/storage/albums/album/aqohkx21cwlrrs71.yml new file mode 100755 index 0000000..019e883 --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqohkx21cwlrrs71.yml @@ -0,0 +1,9 @@ +UID: aqohkx21cwlrrs71 +Slug: testalbum +Type: album +Title: TestAlbum +Order: oldest +Country: zz +CreatedAt: 2021-02-13T21:27:02Z +UpdatedAt: 2021-02-13T21:27:02Z +DeletedAt: 2021-02-13T21:27:02.438478307Z diff --git a/sample-app/photoprism/storage/albums/album/aqohkx21dyhq6xa6.yml b/sample-app/photoprism/storage/albums/album/aqohkx21dyhq6xa6.yml new file mode 100755 index 0000000..7d198f3 --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqohkx21dyhq6xa6.yml @@ -0,0 +1,9 @@ +UID: aqohkx21dyhq6xa6 +Slug: testalbum +Type: album +Title: TestAlbum +Order: oldest +Country: zz +CreatedAt: 2021-02-13T21:27:02Z +UpdatedAt: 2021-02-13T21:27:02Z +DeletedAt: 2021-02-13T21:27:02.460875532Z diff --git a/sample-app/photoprism/storage/albums/album/aqohkx21j9rj6w4f.yml b/sample-app/photoprism/storage/albums/album/aqohkx21j9rj6w4f.yml new file mode 100755 index 0000000..34335b3 --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqohkx21j9rj6w4f.yml @@ -0,0 +1,9 @@ +UID: aqohkx21j9rj6w4f +Slug: testalbum +Type: album +Title: TestAlbum +Order: oldest +Country: zz +CreatedAt: 2021-02-13T21:27:02Z +UpdatedAt: 2021-02-13T21:27:02Z +DeletedAt: 2021-02-13T21:27:02.505591441Z diff --git a/sample-app/photoprism/storage/albums/album/aqohkx22im2tmqpd.yml b/sample-app/photoprism/storage/albums/album/aqohkx22im2tmqpd.yml new file mode 100755 index 0000000..192715f --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqohkx22im2tmqpd.yml @@ -0,0 +1,10 @@ +UID: aqohkx22im2tmqpd +Slug: testalbum +Type: album +Title: TestAlbum +Description: An updated album description +Order: oldest +Country: zz +CreatedAt: 2021-02-13T21:27:02Z +UpdatedAt: 2021-02-13T21:27:02.386442236Z +DeletedAt: 2021-02-13T21:27:02.395711612Z diff --git a/sample-app/photoprism/storage/albums/album/aqohl0w1s0skc6f0.yml b/sample-app/photoprism/storage/albums/album/aqohl0w1s0skc6f0.yml new file mode 100755 index 0000000..629408e --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqohl0w1s0skc6f0.yml @@ -0,0 +1,9 @@ +UID: aqohl0w1s0skc6f0 +Slug: testalbum +Type: album +Title: TestAlbum +Order: oldest +Country: zz +CreatedAt: 2021-02-13T21:29:21Z +UpdatedAt: 2021-02-13T21:29:21Z +DeletedAt: 2021-02-13T21:29:20.538356219Z diff --git a/sample-app/photoprism/storage/albums/album/aqohl0w2dwab02xe.yml b/sample-app/photoprism/storage/albums/album/aqohl0w2dwab02xe.yml new file mode 100755 index 0000000..41a1a9f --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqohl0w2dwab02xe.yml @@ -0,0 +1,9 @@ +UID: aqohl0w2dwab02xe +Slug: testalbum +Type: album +Title: TestAlbum +Order: oldest +Country: zz +CreatedAt: 2021-02-13T21:29:20Z +UpdatedAt: 2021-02-13T21:29:20Z +DeletedAt: 2021-02-13T21:29:20.486868765Z diff --git a/sample-app/photoprism/storage/albums/album/aqohl0w2xt57x1cb.yml b/sample-app/photoprism/storage/albums/album/aqohl0w2xt57x1cb.yml new file mode 100755 index 0000000..885ea41 --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqohl0w2xt57x1cb.yml @@ -0,0 +1,10 @@ +UID: aqohl0w2xt57x1cb +Slug: testalbum +Type: album +Title: TestAlbum +Description: An updated album description +Order: oldest +Country: zz +CreatedAt: 2021-02-13T21:29:20Z +UpdatedAt: 2021-02-13T21:29:20.397458176Z +DeletedAt: 2021-02-13T21:29:20.415107277Z diff --git a/sample-app/photoprism/storage/albums/album/aqohl0wdspiitn0a.yml b/sample-app/photoprism/storage/albums/album/aqohl0wdspiitn0a.yml new file mode 100755 index 0000000..78ae437 --- /dev/null +++ b/sample-app/photoprism/storage/albums/album/aqohl0wdspiitn0a.yml @@ -0,0 +1,9 @@ +UID: aqohl0wdspiitn0a +Slug: testalbum +Type: album +Title: TestAlbum +Order: oldest +Country: zz +CreatedAt: 2021-02-13T21:29:20Z +UpdatedAt: 2021-02-13T21:29:20Z +DeletedAt: 2021-02-13T21:29:20.461857977Z diff --git a/sample-app/photoprism/storage/cache/sessions.json b/sample-app/photoprism/storage/cache/sessions.json index b1aced4..a204d40 100644 --- a/sample-app/photoprism/storage/cache/sessions.json +++ b/sample-app/photoprism/storage/cache/sessions.json @@ -114,6 +114,11 @@ "tokens": null, "expiration": 1613695252131862322 }, + "24227dba42c911f1f3250745252473200d95db38c9006bf6": { + "user": "uqnzie01i1nypnt9", + "tokens": null, + "expiration": 1613856560374865002 + }, "2521ed30985fb1991e3d1271cbf6e2b53840d614647361af": { "user": "uqnzie01i1nypnt9", "tokens": null, @@ -184,6 +189,11 @@ "tokens": null, "expiration": 1613676253240643293 }, + "383cbd715f476ce738e23712a480e3fca123b68f16f2ee69": { + "user": "uqnzie01i1nypnt9", + "tokens": null, + "expiration": 1613856561720200205 + }, "3bd19dc60e5a515d2624f0d712db8471f433416935c2a045": { "user": "uqnzie01i1nypnt9", "tokens": null, @@ -579,6 +589,11 @@ "tokens": null, "expiration": 1613502517447074204 }, + "a69b726d7a6bfab6bac0435a6673d5c390a732470c910f41": { + "user": "uqnzie01i1nypnt9", + "tokens": null, + "expiration": 1613856423690963485 + }, "a83cc511e399c1dab37468d0c64302bf4b68f7e3df5a1e0b": { "user": "uqnzie01i1nypnt9", "tokens": null, @@ -649,6 +664,11 @@ "tokens": null, "expiration": 1613693719704975163 }, + "b9a554547ba1cc81f7d42ea5df395a50968294eb9b574d28": { + "user": "uqnzie01i1nypnt9", + "tokens": null, + "expiration": 1613856422361372143 + }, "bbdbf96d91d72d87fb819d31d7f175b733164975c1802243": { "user": "uqnzie01i1nypnt9", "tokens": null, diff --git a/sample-app/photoprism/storage/index.db b/sample-app/photoprism/storage/index.db index e310cfd7041b70ecda4c850d0440744a9fcab25d..5c287af65047183b18d316a8b8aa55c3cf5bfa7a 100644 GIT binary patch delta 2923 zcmcgudu&r>6z|vjewVS$AviY>9pIMxzU>GzhW$Ylm^v`=0q*v-JJ@(^WgAn{HG-fJ z5NfTy< z?(ejJ&*c6eCO>^63YU94o|W6H8oY4%>n)KcV5E*WHMBqmb2*6}8t}1G*c;dqmSJ%g zVy-fmQxkmEObrY%z_3NDEuyxF*dlC;kS&6?&{Ng#odJ+R&QD^;27Kf}au2zKTu*kB z2KgX4--;C@l1B!akikGVgIJ_1rnd*zbhH+nq6Mc&!6{sD3Kg7!1t&dqWN;p0r8Sbo zK0R8(PGnh@U}5Gj=6B{IGs0c8z*PLJ#7=?a@b~4{w@`F*5*vB9l-@xL?LM2|G&2QG$-5r*>V5Kyk0td%&Hvq-P~} zk{jgqa(!GgH;aSVZ`c&OnGLbC*@?_~=0j#T6JzExx6oJUlk@?4y@g7qY3fJn2=xrr zPBl_f$Y045oa*0v>`7!`tCD_)d5dbO9QK_CkHoeb7wE>;2lB z@^1EqytBO%!Flij*af=4-C&yM56>5-4nSF4)arS$PT>_LAjq;Xi|6ZkK71S03`AZO zYI(6%kg7zXKI=JewJAu>KT5K!!Hnz{|_)BQK6siUK>Xk-2 z-y?MKUCTpils8;PG2EjEd9gRr>N1AAR<*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8jT^hiXmqaEq^6w%PCHw@qBOf90vhGR%ZcZ zfdYVFIWJ%_K?nQD)eB%Zm`fIYaPChbnhPlr(=-i3iS*WHNVhga^~Z&l=7id=nI~Gz z;~ma{GzuVHRrRpu^h}_f)gG`BF4ZHt?v}+s(7z_ZZH|M8Z!LAV0c`(6hs|B3iqlg? z2AqX@SSYXhAx$w%RnauV4IYJ{ahu0#(U4+lx>~9!TEPw_q9_H`2Wtvi%ZrVWt{R3J zjp&*qKZ0$};1q({A;LyPS5(7ke2F$>CtKe;KLS0Yo%sMy>m){p=I diff --git a/sample-app/photoprism/storage/sidecar/2021/02/20210204_031706_5B740007.yml b/sample-app/photoprism/storage/sidecar/2021/02/20210204_031706_5B740007.yml index 011d67a..3eb3051 100755 --- a/sample-app/photoprism/storage/sidecar/2021/02/20210204_031706_5B740007.yml +++ b/sample-app/photoprism/storage/sidecar/2021/02/20210204_031706_5B740007.yml @@ -3,7 +3,7 @@ UID: pqnzigq351j2fqgn Type: image Title: A really great photo! TitleSrc: manual -Description: 'Sample App Description: 2021-02-13 13:17:39.073524303 -0800 PST m=+6.526679853' +Description: 'Sample App Description: 2021-02-13 13:29:20.603412741 -0800 PST m=+6.504617892' DescriptionSrc: manual OriginalName: IMG_3044 Year: -1 @@ -13,5 +13,5 @@ Details: Keywords: green, tambourine KeywordsSrc: manual CreatedAt: 2021-02-04T03:17:14.613092062Z -UpdatedAt: 2021-02-13T21:17:39.081685026Z -EditedAt: 2021-02-13T21:17:39Z +UpdatedAt: 2021-02-13T21:29:20.611389111Z +EditedAt: 2021-02-13T21:29:21Z diff --git a/test/regression_test.go b/test/regression_test.go new file mode 100644 index 0000000..3fd7354 --- /dev/null +++ b/test/regression_test.go @@ -0,0 +1,22 @@ +package test + +import ( + "testing" + + "github.com/kris-nova/photoprism-client-go" +) + +// Trailing slash issue +// https://github.com/kris-nova/photoprism-client-go/issues/2 +func TestRegressionIssue2(t *testing.T) { + testStrings := []string{"localhost/", "localhost///////", "localhost//"} + goal := "localhost" + for _, str := range testStrings { + client := photoprism.New(str) + if client.ConnectionString() != goal { + t.Error("Failed to trim suffix / in client connection string") + t.FailNow() + } + } + +}