From e89e3e99d96549c1a3b64c0eae42f6f5079962b3 Mon Sep 17 00:00:00 2001 From: simulot Date: Tue, 27 Feb 2024 21:55:33 +0100 Subject: [PATCH 1/2] Fixes #141 chore: follow immich 1.95.0 API changes --- cmd/duplicate/duplicate.go | 2 +- cmd/metadata/metadata.go | 2 +- cmd/stack/stack.go | 2 +- cmd/upload/e2e_upload_folder_test.go | 4 +- cmd/upload/upload.go | 2 +- cmd/upload/upload_test.go | 4 +- immich/asset.go | 58 ++--------- immich/call.go | 91 +++-------------- immich/e2e_asset_test.go | 10 +- immich/immich.go | 12 ++- immich/metada_test.go | 141 +++++++++++++++++++++++++++ immich/metadata.go | 66 +++++++++++++ 12 files changed, 251 insertions(+), 143 deletions(-) create mode 100644 immich/metada_test.go create mode 100644 immich/metadata.go diff --git a/cmd/duplicate/duplicate.go b/cmd/duplicate/duplicate.go index 118a398c..4dd7f1ff 100644 --- a/cmd/duplicate/duplicate.go +++ b/cmd/duplicate/duplicate.go @@ -69,7 +69,7 @@ func DuplicateCommand(ctx context.Context, common *cmd.SharedFlags, args []strin dupCount := 0 app.Jnl.Log.MessageContinue(logger.OK, "Get server's assets...") - err = app.Immich.GetAllAssetsWithFilter(ctx, nil, func(a *immich.Asset) { + err = app.Immich.GetAllAssetsWithFilter(ctx, func(a *immich.Asset) { if a.IsTrashed { return } diff --git a/cmd/metadata/metadata.go b/cmd/metadata/metadata.go index 274427fc..856d9a73 100644 --- a/cmd/metadata/metadata.go +++ b/cmd/metadata/metadata.go @@ -61,7 +61,7 @@ func MetadataCommand(ctx context.Context, common *cmd.SharedFlags, args []string } app.Jnl.Log.MessageContinue(logger.OK, "Get server's assets...") - list, err := app.Immich.GetAllAssets(ctx, nil) + list, err := app.Immich.GetAllAssets(ctx) if err != nil { return err } diff --git a/cmd/stack/stack.go b/cmd/stack/stack.go index 26394a9a..1842abd1 100644 --- a/cmd/stack/stack.go +++ b/cmd/stack/stack.go @@ -57,7 +57,7 @@ func NewStackCommand(ctx context.Context, common *cmd.SharedFlags, args []string app.Jnl.Log.MessageContinue(logger.OK, "Get server's assets...") assetCount := 0 - err = app.Immich.GetAllAssetsWithFilter(ctx, nil, func(a *immich.Asset) { + err = app.Immich.GetAllAssetsWithFilter(ctx, func(a *immich.Asset) { if a.IsTrashed { return } diff --git a/cmd/upload/e2e_upload_folder_test.go b/cmd/upload/e2e_upload_folder_test.go index d0c3f253..20a31a83 100644 --- a/cmd/upload/e2e_upload_folder_test.go +++ b/cmd/upload/e2e_upload_folder_test.go @@ -390,7 +390,7 @@ func resetImmich(ic *immich.ImmichClient, user string) error { } } - assets, err := ic.GetAllAssets(context.Background(), nil) + assets, err := ic.GetAllAssets(context.Background()) if err != nil { return err } @@ -405,7 +405,7 @@ func resetImmich(ic *immich.ImmichClient, user string) error { attempts := 5 for attempts > 0 { - assets, err := ic.GetAllAssets(context.Background(), nil) + assets, err := ic.GetAllAssets(context.Background()) if err != nil { return err } diff --git a/cmd/upload/upload.go b/cmd/upload/upload.go index d951a16d..3af593fc 100644 --- a/cmd/upload/upload.go +++ b/cmd/upload/upload.go @@ -164,7 +164,7 @@ func NewUpCmd(ctx context.Context, common *cmd.SharedFlags, args []string) (*UpC } app.Jnl.Log.OK("Ask for server's assets...") var list []*immich.Asset - err = app.Immich.GetAllAssetsWithFilter(ctx, nil, func(a *immich.Asset) { + err = app.Immich.GetAllAssetsWithFilter(ctx, func(a *immich.Asset) { if a.IsTrashed { return } diff --git a/cmd/upload/upload_test.go b/cmd/upload/upload_test.go index 34370501..705052e5 100644 --- a/cmd/upload/upload_test.go +++ b/cmd/upload/upload_test.go @@ -19,7 +19,7 @@ import ( type stubIC struct{} -func (c *stubIC) GetAllAssetsWithFilter(context.Context, *immich.GetAssetOptions, func(*immich.Asset)) error { +func (c *stubIC) GetAllAssetsWithFilter(context.Context, func(*immich.Asset)) error { return nil } @@ -77,7 +77,7 @@ func (c *stubIC) GetAssetAlbums(ctx context.Context, id string) ([]immich.AlbumS return nil, nil } -func (c *stubIC) GetAllAssets(ctx context.Context, opt *immich.GetAssetOptions) ([]*immich.Asset, error) { +func (c *stubIC) GetAllAssets(ctx context.Context) ([]*immich.Asset, error) { return nil, nil } diff --git a/immich/asset.go b/immich/asset.go index 37721964..af6f705b 100644 --- a/immich/asset.go +++ b/immich/asset.go @@ -174,57 +174,6 @@ func (o *GetAssetOptions) Values() url.Values { return v } -// GetAllAssets get all user's assets using the paged API searchAssets -// -// It calls the server for IMAGE, VIDEO, normal item, trashed Items - -func (ic *ImmichClient) GetAllAssets(ctx context.Context, opt *GetAssetOptions) ([]*Asset, error) { - var r []*Asset - - for _, t := range []string{"IMAGE", "VIDEO", "AUDIO", "OTHER"} { - values := opt.Values() - values.Set("type", t) - values.Set("withExif", "true") - values.Set("isVisible", "true") - values.Del("trashedBefore") - err := ic.newServerCall(ctx, "GetAllAssets", setPaginator()).do(get("/assets", setURLValues(values), setAcceptJSON()), responseAccumulateJSON(&r)) - if err != nil { - return r, err - } - values.Set("trashedBefore", "9999-01-01") - err = ic.newServerCall(ctx, "GetAllAssets", setPaginator()).do(get("/assets", setURLValues(values), setAcceptJSON()), responseAccumulateJSON(&r)) - if err != nil { - return r, err - } - } - return r, nil -} - -// GetAllAssetsWithFilter get all user's assets using the paged API searchAssets and apply a filter -// TODO: rename this function, it's not a filter, it uses a callback function for each item -// -// It calls the server for IMAGE, VIDEO, normal item, trashed Items -func (ic *ImmichClient) GetAllAssetsWithFilter(ctx context.Context, opt *GetAssetOptions, filter func(*Asset)) error { - for _, t := range []string{"IMAGE", "VIDEO", "AUDIO", "OTHER"} { - values := opt.Values() - values.Set("type", t) - values.Set("withExif", "true") - values.Set("isVisible", "true") - values.Del("trashedBefore") - err := ic.newServerCall(ctx, "GetAllAssets", setPaginator()).do(get("/assets", setURLValues(values), setAcceptJSON()), responseJSONWithFilter(filter)) - if err != nil { - return err - } - values.Set("trashedBefore", "9999-01-01") - err = ic.newServerCall(ctx, "GetAllAssets", setPaginator()).do(get("/assets", setURLValues(values), setAcceptJSON()), responseJSONWithFilter(filter)) - if err != nil { - return err - } - } - - return nil -} - func (ic *ImmichClient) DeleteAssets(ctx context.Context, id []string, forceDelete bool) error { req := struct { Force bool `json:"force"` @@ -238,8 +187,13 @@ func (ic *ImmichClient) DeleteAssets(ctx context.Context, id []string, forceDele } func (ic *ImmichClient) GetAssetByID(ctx context.Context, id string) (*Asset, error) { + body := struct { + WithExif bool `json:"withExif,omitempty"` + IsVisible bool `json:"isVisible,omitempty"` + ID string `json:"id"` + }{WithExif: true, IsVisible: true, ID: id} r := Asset{} - err := ic.newServerCall(ctx, "GetAssetByID").do(get("/asset/assetById/"+id, setAcceptJSON()), responseJSON(&r)) + err := ic.newServerCall(ctx, "GetAssetByID").do(post("/search/metadata", "application/json", setAcceptJSON(), setJSONBody(body)), responseJSON(&r)) return &r, err } diff --git a/immich/call.go b/immich/call.go index 482e6ce1..6efecbe2 100644 --- a/immich/call.go +++ b/immich/call.go @@ -8,8 +8,6 @@ import ( "fmt" "io" "net/http" - "net/url" - "strconv" "strings" ) @@ -28,7 +26,6 @@ type serverCall struct { ic *ImmichClient err error ctx context.Context - p *paginator } type serverCallOption func(sc *serverCall) error @@ -120,32 +117,6 @@ func (sc *serverCall) joinError(err error) error { return err } -// paginator controls the paged API calls -type paginator struct { - pageNumber int // current page - pageParameter string // page parameter name on the URL - EOF bool // true when the last page was empty -} - -func (p paginator) setPage(v url.Values) { - v.Set(p.pageParameter, strconv.Itoa(p.pageNumber)) -} - -func (p *paginator) nextPage() { - p.pageNumber++ -} - -func setPaginator() serverCallOption { - return func(sc *serverCall) error { - p := paginator{ - pageParameter: "page", - pageNumber: 1, - } - sc.p = &p - return nil - } -} - type requestFunction func(sc *serverCall) *http.Request func (sc *serverCall) request(method string, url string, opts ...serverRequestOption) *http.Request { @@ -199,25 +170,6 @@ func put(url string, opts ...serverRequestOption) requestFunction { } func (sc *serverCall) do(fnRequest requestFunction, opts ...serverResponseOption) error { - if sc.err != nil || fnRequest == nil { - return sc.Err(nil, nil, nil) - } - - if sc.p == nil { - return sc._callDo(fnRequest, opts...) - } - - for !sc.p.EOF { - err := sc._callDo(fnRequest, opts...) - if err != nil { - return err - } - sc.p.nextPage() - } - return nil -} - -func (sc *serverCall) _callDo(fnRequest requestFunction, opts ...serverResponseOption) error { var ( resp *http.Response err error @@ -228,11 +180,6 @@ func (sc *serverCall) _callDo(fnRequest requestFunction, opts ...serverResponseO return sc.Err(req, nil, nil) } - if sc.p != nil { - v := req.URL.Query() - sc.p.setPage(v) - req.URL.RawQuery = v.Encode() - } if sc.ic.APITrace /* && req.Header.Get("Content-Type") == "application/json"*/ { _ = sc.joinError(setTraceJSONRequest()(sc, req)) } @@ -316,21 +263,6 @@ func setContentType(cType string) serverRequestOption { } } -func setURLValues(values url.Values) serverRequestOption { - return func(sc *serverCall, req *http.Request) error { - if values != nil { - rValues := req.URL.Query() - for k, v := range values { - for _, s := range v { - rValues.Set(k, s) - } - } - req.URL.RawQuery = rValues.Encode() - } - return nil - } -} - type serverResponseOption func(sc *serverCall, resp *http.Response) error func responseJSON[T any](object *T) serverResponseOption { @@ -349,11 +281,10 @@ func responseJSON[T any](object *T) serverResponseOption { } } +/* func responseAccumulateJSON[T any](acc *[]T) serverResponseOption { return func(sc *serverCall, resp *http.Response) error { - if sc.p != nil { - sc.p.EOF = true - } + eof := true if resp != nil { if resp.Body != nil { defer resp.Body.Close() @@ -366,21 +297,23 @@ func responseAccumulateJSON[T any](acc *[]T) serverResponseOption { return err } if len(arr) > 0 && sc.p != nil { - sc.p.EOF = false + eof = false } (*acc) = append((*acc), arr...) + if eof { + sc.p.setEOF() + } return nil } } return errors.New("can't decode nil response") } } - +*/ +/* func responseJSONWithFilter[T any](filter func(*T)) serverResponseOption { return func(sc *serverCall, resp *http.Response) error { - if sc.p != nil { - sc.p.EOF = true - } + eof := true if resp != nil { if resp.Body != nil { defer resp.Body.Close() @@ -403,15 +336,19 @@ func responseJSONWithFilter[T any](filter func(*T)) serverResponseOption { return err } if sc.p != nil { - sc.p.EOF = false + eof = false } filter(&o) } // read closing bracket "]" _, err = dec.Token() + if eof { + sc.p.setEOF() + } return err } } return errors.New("can't decode nil response") } } +*/ diff --git a/immich/e2e_asset_test.go b/immich/e2e_asset_test.go index 3321422a..9bd3c52f 100644 --- a/immich/e2e_asset_test.go +++ b/immich/e2e_asset_test.go @@ -82,7 +82,8 @@ func checkImmich(t *testing.T, host, key, user string) { } } - paginated, err := ic.GetAllAssets(ctx, nil) + t.Log("start paginated") + paginated, err := ic.GetAllAssets(ctx) if err != nil { t.Errorf("can't get assets from %s: %s", host, err) } @@ -92,6 +93,7 @@ func checkImmich(t *testing.T, host, key, user string) { paginatedCounts[aa.Type] = paginatedCounts[aa.Type] + 1 } + t.Log("start old method") all, err := ic.getAllAssetsIDs(ctx, nil) if err != nil { t.Errorf("can't get assets from %s: %s", host, err) @@ -122,14 +124,14 @@ func TestAssetImmich(t *testing.T) { // t.Run("WithDebugCredentials", func(t *testing.T) { // h, k, u := getImmichDebugCreds() // checkImmich(t, h, k, u) - // // }) + // }) t.Run("WithProductionCredentials", func(t *testing.T) { h, k, u := getImmichProdCreds() checkImmich(t, h, k, u) }) // t.Run("WithDemoCredentials", func(t *testing.T) { // // h, k, u := getImmichProdCreds() - // checkImmich(t, "https://demo.immich.app", "jQJ39xD5hRCCIcA3XaCVZ7vJWeDefZKrSdKF10jVmo", "") + // checkImmich(t, "https://demo.immich.app", "5nOUy9yN4u2tB3L626Pl4vjN6G7AvGzyoDQP5qJvKD4", "") // }) } @@ -137,7 +139,7 @@ func TestAssetImmich(t *testing.T) { func (ic *ImmichClient) getAllAssetsIDs(ctx context.Context, opt *GetAssetOptions) ([]*Asset, error) { var r []*Asset - err := ic.newServerCall(ctx, "GetAllAssets").do(get("/asset", setURLValues(opt.Values()), setAcceptJSON()), responseJSON(&r)) + err := ic.newServerCall(ctx, "GetAllAssets").do(get("/asset", setAcceptJSON()), responseJSON(&r)) return r, err } diff --git a/immich/immich.go b/immich/immich.go index 8cf99c52..03416766 100644 --- a/immich/immich.go +++ b/immich/immich.go @@ -22,10 +22,10 @@ type ImmichInterface interface { GetServerStatistics(ctx context.Context) (ServerStatistics, error) UpdateAsset(ctx context.Context, ID string, a *browser.LocalAssetFile) (*Asset, error) - GetAllAssets(ctx context.Context, opt *GetAssetOptions) ([]*Asset, error) + GetAllAssets(ctx context.Context) ([]*Asset, error) AddAssetToAlbum(context.Context, string, []string) ([]UpdateAlbumResult, error) UpdateAssets(ctx context.Context, IDs []string, isArchived bool, isFavorite bool, latitude float64, longitude float64, removeParent bool, stackParentID string) error - GetAllAssetsWithFilter(context.Context, *GetAssetOptions, func(*Asset)) error + GetAllAssetsWithFilter(context.Context, func(*Asset)) error AssetUpload(context.Context, *browser.LocalAssetFile) (AssetResponse, error) DeleteAssets(context.Context, []string, bool) error @@ -196,3 +196,11 @@ func (t *ImmichTime) UnmarshalJSON(b []byte) error { t.Time = ts.In(local) return nil } + +func (t ImmichTime) MarshalJSON() ([]byte, error) { + if t.IsZero() { + return json.Marshal("") + } + + return json.Marshal(t.Time.Format("\"" + time.RFC3339 + "\"")) +} diff --git a/immich/metada_test.go b/immich/metada_test.go new file mode 100644 index 00000000..ea08719a --- /dev/null +++ b/immich/metada_test.go @@ -0,0 +1,141 @@ +package immich + +import ( + "bytes" + "encoding/json" + "testing" +) + +func Test_searchMetadataRequest(t *testing.T) { + body := `{ + "albums": { + "total": 0, + "count": 0, + "items": [], + "facets": [] + }, + "assets": { + "total": 2, + "count": 2, + "items": [ + { + "id": "90f33f69-4bc1-4ec4-b683-7c3f30ea6e57", + "type": "IMAGE", + "thumbhash": "4SgGDQKzh2+Id3iYeIiYeH9s+cmW", + "localDateTime": "2024-02-26T17:08:30.000Z", + "resized": true, + "duration": "0:00:00.00000", + "livePhotoVideoId": null, + "hasMetadata": true, + "deviceAssetId": "1000007507", + "ownerId": "bac3e8ec-d6ef-4721-b14b-079d655438d4", + "deviceId": "335475d885a9894fad34eed6c4663867e7412499d69e2fcba8d7d5290542dbeb", + "libraryId": "e4ca1939-6149-44a8-8be5-f6415183fb3d", + "originalPath": "upload/library/admin/2024/2024-02-26/IMG-20240226-WA0000.jpg", + "originalFileName": "IMG-20240226-WA0000", + "fileCreatedAt": "2024-02-26T17:08:30.000Z", + "fileModifiedAt": "2024-02-26T17:08:31.000Z", + "updatedAt": "2024-02-26T17:30:18.517Z", + "isFavorite": false, + "isArchived": false, + "isTrashed": false, + "exifInfo": { + "make": null, + "model": null, + "exifImageWidth": 1200, + "exifImageHeight": 1600, + "fileSizeInByte": 237206, + "orientation": null, + "dateTimeOriginal": "2024-02-26T17:08:30.000Z", + "modifyDate": "2024-02-26T17:08:31.000Z", + "timeZone": null, + "lensModel": null, + "fNumber": null, + "focalLength": null, + "iso": null, + "exposureTime": null, + "latitude": null, + "longitude": null, + "city": null, + "state": null, + "country": null, + "description": "", + "projectionType": null + }, + "people": [], + "checksum": "mDk/Ipx2lm6N28WW7amedczy7KY=", + "stackCount": null, + "isExternal": false, + "isOffline": false, + "isReadOnly": false + }, + { + "id": "d6f5a992-b3ce-42c3-bd0f-6d8785d164da", + "type": "IMAGE", + "thumbhash": "pBgKBYCKiHdvdYiSh6hnhKpfsMgG", + "localDateTime": "2024-02-25T11:31:23.000Z", + "resized": true, + "duration": "0:00:00.00000", + "livePhotoVideoId": null, + "hasMetadata": true, + "deviceAssetId": "1000007495", + "ownerId": "bac3e8ec-d6ef-4721-b14b-079d655438d4", + "deviceId": "335475d885a9894fad34eed6c4663867e7412499d69e2fcba8d7d5290542dbeb", + "libraryId": "e4ca1939-6149-44a8-8be5-f6415183fb3d", + "originalPath": "upload/library/admin/2024/2024-02-25/IMG-20240225-WA0001.jpg", + "originalFileName": "IMG-20240225-WA0001", + "fileCreatedAt": "2024-02-25T11:31:23.000Z", + "fileModifiedAt": "2024-02-25T11:31:24.000Z", + "updatedAt": "2024-02-25T18:26:31.410Z", + "isFavorite": false, + "isArchived": false, + "isTrashed": false, + "exifInfo": { + "make": null, + "model": null, + "exifImageWidth": 1280, + "exifImageHeight": 964, + "fileSizeInByte": 95295, + "orientation": null, + "dateTimeOriginal": "2024-02-25T11:31:23.000Z", + "modifyDate": "2024-02-25T11:31:24.000Z", + "timeZone": null, + "lensModel": null, + "fNumber": null, + "focalLength": null, + "iso": null, + "exposureTime": null, + "latitude": null, + "longitude": null, + "city": null, + "state": null, + "country": null, + "description": "", + "projectionType": null + }, + "people": [], + "checksum": "m8eMvM0JiUYFp2A/OqV30qio780=", + "stackCount": null, + "isExternal": false, + "isOffline": false, + "isReadOnly": false + } + ], + "facets": [], + "nextPage": "2" + } + }` + + rest := searchMetadataResponse{} + err := json.NewDecoder(bytes.NewBufferString(body)).Decode(&rest) + if err != nil { + t.Error(err) + return + } + if len(rest.Assets.Items) != 2 { + t.Errorf("expecting 2 assets, got: %d", len(rest.Assets.Items)) + } + if rest.Assets.NextPage != 2 { + t.Errorf("expecting next page, got: %d", rest.Assets.NextPage) + } +} diff --git a/immich/metadata.go b/immich/metadata.go new file mode 100644 index 00000000..915cf40f --- /dev/null +++ b/immich/metadata.go @@ -0,0 +1,66 @@ +package immich + +import ( + "context" +) + +type searchMetadataBody interface { + setPage(p int) +} + +type searchMetadataResponse struct { + Assets struct { + Total int `json:"total"` + Count int `json:"count"` + Items []*Asset `json:"items"` + NextPage int `json:"nextPage,string"` + } +} + +type searchMetadataGetAllBody struct { + Page int `json:"page"` + WithExif bool `json:"withExif,omitempty"` + IsVisible bool `json:"isVisible,omitempty"` +} + +func (sb *searchMetadataGetAllBody) setPage(p int) { + sb.Page = p +} + +func (ic *ImmichClient) callSearchMetadata(ctx context.Context, req searchMetadataBody, filter func(*Asset)) error { + req.setPage(1) + for { + resp := searchMetadataResponse{} + err := ic.newServerCall(ctx, "GetAllAssets").do(post("/search/metadata", "application/json", setJSONBody(&req), setAcceptJSON()), responseJSON(&resp)) + if err != nil { + return err + } + + for _, a := range resp.Assets.Items { + filter(a) + } + + if resp.Assets.NextPage == 0 { + break + } + req.setPage(resp.Assets.NextPage) + } + return nil + +} + +func (ic *ImmichClient) GetAllAssets(ctx context.Context) ([]*Asset, error) { + var assets []*Asset + + req := searchMetadataGetAllBody{Page: 1, WithExif: true, IsVisible: true} + err := ic.callSearchMetadata(ctx, &req, func(asset *Asset) { assets = append(assets, asset) }) + if err != nil { + return nil, err + } + return assets, nil +} + +func (ic *ImmichClient) GetAllAssetsWithFilter(ctx context.Context, filter func(*Asset)) error { + req := searchMetadataGetAllBody{Page: 1, WithExif: true, IsVisible: true} + return ic.callSearchMetadata(ctx, &req, filter) +} From 40ffd8728c8860bf7d22a5990b33dd159dc1245c Mon Sep 17 00:00:00 2001 From: simulot Date: Tue, 27 Feb 2024 22:04:06 +0100 Subject: [PATCH 2/2] fix linter errors --- immich/call.go | 9 +-------- immich/e2e_asset_test.go | 8 ++++---- immich/metadata.go | 1 - 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/immich/call.go b/immich/call.go index 6efecbe2..fbc6abee 100644 --- a/immich/call.go +++ b/immich/call.go @@ -28,8 +28,6 @@ type serverCall struct { ctx context.Context } -type serverCallOption func(sc *serverCall) error - // callError represents errors returned by the server type callError struct { endPoint string @@ -82,17 +80,12 @@ func (ce callError) Error() string { return b.String() } -func (ic *ImmichClient) newServerCall(ctx context.Context, api string, opts ...serverCallOption) *serverCall { +func (ic *ImmichClient) newServerCall(ctx context.Context, api string) *serverCall { sc := &serverCall{ endPoint: api, ic: ic, ctx: ctx, } - if sc.err == nil { - for _, opt := range opts { - _ = sc.joinError(opt(sc)) - } - } return sc } diff --git a/immich/e2e_asset_test.go b/immich/e2e_asset_test.go index 9bd3c52f..76b4dc7d 100644 --- a/immich/e2e_asset_test.go +++ b/immich/e2e_asset_test.go @@ -50,7 +50,7 @@ func getImmichDebugCreds() (host, key, user string) { return } -func getImmichClient(t *testing.T, host, key, user string) *ImmichClient { +func getImmichClient(t *testing.T, host, key, _ string) *ImmichClient { if host == "" { host = "http://localhost:2283" } @@ -62,7 +62,7 @@ func getImmichClient(t *testing.T, host, key, user string) *ImmichClient { return ic } -func checkImmich(t *testing.T, host, key, user string) { +func checkImmich(t *testing.T, host, key, _ string) { ic, err := NewImmichClient(host, key, false) if err != nil { t.Errorf("can't connect to %s: %s", host, err) @@ -94,7 +94,7 @@ func checkImmich(t *testing.T, host, key, user string) { } t.Log("start old method") - all, err := ic.getAllAssetsIDs(ctx, nil) + all, err := ic.getAllAssetsIDs(ctx) if err != nil { t.Errorf("can't get assets from %s: %s", host, err) } @@ -136,7 +136,7 @@ func TestAssetImmich(t *testing.T) { } // getAllAssetsIDs call the not paginated interface as comparison point -func (ic *ImmichClient) getAllAssetsIDs(ctx context.Context, opt *GetAssetOptions) ([]*Asset, error) { +func (ic *ImmichClient) getAllAssetsIDs(ctx context.Context) ([]*Asset, error) { var r []*Asset err := ic.newServerCall(ctx, "GetAllAssets").do(get("/asset", setAcceptJSON()), responseJSON(&r)) diff --git a/immich/metadata.go b/immich/metadata.go index 915cf40f..3b704586 100644 --- a/immich/metadata.go +++ b/immich/metadata.go @@ -46,7 +46,6 @@ func (ic *ImmichClient) callSearchMetadata(ctx context.Context, req searchMetada req.setPage(resp.Assets.NextPage) } return nil - } func (ic *ImmichClient) GetAllAssets(ctx context.Context) ([]*Asset, error) {