Skip to content

Commit

Permalink
Unexpected Discrepancy in 'Server has same quality' Metric After Re-u…
Browse files Browse the repository at this point in the history
…ploading Images

Fixes #359
  • Loading branch information
simulot committed Jul 7, 2024
1 parent dafec49 commit 5b7dafd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions cmd/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ func (app *UpCmd) UploadAsset(ctx context.Context, a *browser.LocalAssetFile) (s
if a.LivePhoto != nil {
liveResp, err = app.Immich.AssetUpload(ctx, a.LivePhoto)
if err == nil {
if liveResp.Duplicate {
if liveResp.Status == immich.UploadDuplicate {
app.Jnl.Record(ctx, fileevent.UploadServerDuplicate, a.LivePhoto, a.LivePhoto.FileName, "info", "the server has this file")
} else {
a.LivePhotoID = liveResp.ID
Expand All @@ -798,7 +798,7 @@ func (app *UpCmd) UploadAsset(ctx context.Context, a *browser.LocalAssetFile) (s
}
resp, err = app.Immich.AssetUpload(ctx, a)
if err == nil {
if resp.Duplicate {
if resp.Status == immich.UploadDuplicate {
app.Jnl.Record(ctx, fileevent.UploadServerDuplicate, a, a.FileName, "info", "the server has this file")
} else {
app.Jnl.Record(ctx, fileevent.Uploaded, a, a.FileName, "capture date", a.Metadata.DateTaken.String())
Expand All @@ -816,7 +816,7 @@ func (app *UpCmd) UploadAsset(ctx context.Context, a *browser.LocalAssetFile) (s
resp.ID = uuid.NewString()
app.Jnl.Record(ctx, fileevent.Uploaded, a, a.FileName, "capture date", a.Metadata.DateTaken.String())
}
if !resp.Duplicate {
if resp.Status != immich.UploadDuplicate {
if a.LivePhoto != nil {
app.AssetIndex.AddLocalAsset(a, liveResp.ID)
}
Expand Down
10 changes: 8 additions & 2 deletions immich/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ import (
)

type AssetResponse struct {
ID string `json:"id"`
Duplicate bool `json:"duplicate"`
ID string `json:"id"`
Status string `json:"status"`
}

const (
UploadCreated = "created"
UploadReplaced = "replaced"
UploadDuplicate = "duplicate"
)

func formatDuration(duration time.Duration) string {
hours := duration / time.Hour
duration -= hours * time.Hour
Expand Down

0 comments on commit 5b7dafd

Please sign in to comment.