renamed some structs to make the private
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user