Skip to content

Commit

Permalink
fix of -Album option
Browse files Browse the repository at this point in the history
  • Loading branch information
laaqxdze1k committed Sep 6, 2023
1 parent 0f1ea52 commit 4f4efed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion cmdupload/assets.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmdupload

import (
"fmt"
"immich-go/immich"
"immich-go/immich/assets"
"path"
Expand All @@ -21,7 +22,7 @@ func (ai *AssetIndex) ReIndex() {
ai.byID = map[string]*immich.Asset{}

for _, a := range ai.assets {
ID := a.DeviceAssetID
ID := fmt.Sprintf("%s-%d", strings.ToUpper(path.Base(a.OriginalFileName)), a.ExifInfo.FileSizeInByte)
l := ai.byHash[a.Checksum]
l = append(l, a)
ai.byHash[a.Checksum] = l
Expand Down
10 changes: 4 additions & 6 deletions cmdupload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"immich-go/immich/metadata"
"io/fs"
"math"
"path"
"path/filepath"
"runtime"
"strings"
Expand Down Expand Up @@ -173,10 +172,6 @@ func (app *UpCmd) handleAsset(ctx context.Context, a *assets.LocalAssetFile) err
}()
app.mediaCount++

if _, exists := app.AssetIndex.byID[a.DeviceAssetID()]; exists {
return nil
}

if !app.KeepPartner && a.FromPartner {
return nil
}
Expand Down Expand Up @@ -339,6 +334,9 @@ func (app *UpCmd) UploadAsset(ctx context.Context, a *assets.LocalAssetFile) {
for _, al := range a.Album {
app.AddToAlbum(resp.ID, al)
}
if app.ImportIntoAlbum != "" {
app.AddToAlbum(resp.ID, app.ImportIntoAlbum)
}
} else {
app.logger.MessageTerminate(logger.Warning, "already exists on the server")
}
Expand Down Expand Up @@ -552,7 +550,7 @@ func (ai *AssetIndex) ShouldUpload(la *assets.LocalAssetFile) (*Advice, error) {
return nil, err
}
}
ID := fmt.Sprintf("%s-%d", path.Base(la.Title), la.Size())
ID := la.DeviceAssetID()

sa := ai.byID[ID]
if sa != nil {
Expand Down
6 changes: 4 additions & 2 deletions immich/assets/localfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"path"
"path/filepath"
"strings"
"time"
)

Expand Down Expand Up @@ -161,7 +162,7 @@ func (l *LocalAssetFile) Name() string {
return "name not resolved"
}
func (l *LocalAssetFile) Size() int64 {
if l.resolve() != nil {
if l.resolve() == nil {
return l.fInfo.Size()
}
return 0
Expand Down Expand Up @@ -219,7 +220,8 @@ func (l *LocalAssetFile) Remove() error {

func (l *LocalAssetFile) DeviceAssetID() string {
if err := l.resolve(); err == nil {
return fmt.Sprintf("%s-%d", path.Base(l.Title), l.Size())
n := strings.TrimSuffix(path.Base(l.Title), path.Ext(l.Title))
return fmt.Sprintf("%s-%d", strings.ToUpper(n), l.Size())
}
return "Not resolved"
}

0 comments on commit 4f4efed

Please # to comment.