diff --git a/internal/hasher.go b/internal/hasher.go index cd970d6..81537bf 100644 --- a/internal/hasher.go +++ b/internal/hasher.go @@ -7,7 +7,7 @@ import ( "os" ) -func hashFiles(assets []AssetState) (map[int]string, error) { +func hashFiles(assets []assetState) (map[int]string, error) { results := make(map[int]string) for i, p := range assets { diff --git a/internal/immich.go b/internal/immich.go index 9729630..9b9b6dc 100644 --- a/internal/immich.go +++ b/internal/immich.go @@ -41,18 +41,18 @@ type assetBulkUploadCheckResult struct { Reason string // can be "duplicate" or "unsupportedFormat" (i don't know what they mean by this) } -type APIKeyTransport struct { +type apiKeyTransport struct { APIKey string } -func (t *APIKeyTransport) RoundTrip(req *http.Request) (*http.Response, error) { +func (t *apiKeyTransport) RoundTrip(req *http.Request) (*http.Response, error) { req = req.Clone(req.Context()) req.Header.Add("x-api-key", t.APIKey) return http.DefaultTransport.RoundTrip(req) } func newImmichHttpClient(apiKey string) http.Client { - transport := APIKeyTransport{ + transport := apiKeyTransport{ APIKey: apiKey, } diff --git a/internal/localstate.go b/internal/localstate.go index f8ce3f6..89e0f8e 100644 --- a/internal/localstate.go +++ b/internal/localstate.go @@ -7,21 +7,21 @@ import ( "os" ) -type AssetState struct { +type assetState struct { FilePath string ImmichID string } -type LocalState struct { - Assets []AssetState +type localState struct { + Assets []assetState GameIDs map[string]string } -func loadLocalState(filename string) (*LocalState, error) { +func loadLocalState(filename string) (*localState, error) { file, err := os.Open(filename) if err != nil { if errors.Is(err, os.ErrNotExist) { - return &LocalState{Assets: []AssetState{}, GameIDs: map[string]string{}}, nil + return &localState{Assets: []assetState{}, GameIDs: map[string]string{}}, nil } return nil, err } @@ -31,7 +31,7 @@ func loadLocalState(filename string) (*LocalState, error) { return nil, err } - var data LocalState + var data localState err = json.Unmarshal(content, &data) if err != nil { return nil, err @@ -40,7 +40,7 @@ func loadLocalState(filename string) (*LocalState, error) { return &data, nil } -func saveLocalState(filename string, state LocalState) error { +func saveLocalState(filename string, state localState) error { content, err := json.Marshal(state) if err != nil { return err diff --git a/internal/steam.go b/internal/steam.go index a63470d..4d36197 100644 --- a/internal/steam.go +++ b/internal/steam.go @@ -10,7 +10,7 @@ import ( const UNKOWN_GAME_GAME = "Unkown" -type SteamAPIResponse struct { +type steamAPIResponse struct { Success bool `json:"success"` Data struct { Name string `json:"name"` @@ -46,7 +46,7 @@ func fetchGameName(appID string) (string, error) { return "", fmt.Errorf("reading response for %s: %s", appID, err) } - var result map[string]SteamAPIResponse + var result map[string]steamAPIResponse if err := json.Unmarshal(body, &result); err != nil { return "", fmt.Errorf("parsing response for %s: %s", appID, err) } diff --git a/internal/steamimmich.go b/internal/steamimmich.go index c9b57bd..2caf86f 100644 --- a/internal/steamimmich.go +++ b/internal/steamimmich.go @@ -43,7 +43,7 @@ func Run(config Config) { for _, filepath := range files { - idx := slices.IndexFunc(localState.Assets, func(e AssetState) bool { return e.FilePath == filepath }) + idx := slices.IndexFunc(localState.Assets, func(e assetState) bool { return e.FilePath == filepath }) if idx != -1 { log.Printf("Asset already uploaded: %s", filepath) @@ -59,7 +59,7 @@ func Run(config Config) { log.Printf("Assest uploaded: %s (%s) %s with ID: %s", gameName, appid, filepath, res.ID) - localState.Assets = append(localState.Assets, AssetState{FilePath: filepath, ImmichID: res.ID}) + localState.Assets = append(localState.Assets, assetState{FilePath: filepath, ImmichID: res.ID}) assetsInGame = append(assetsInGame, res.ID) }