Skip to content

Commit

Permalink
fix(importer): don't attempt to import a thumbnail for a media we hav…
Browse files Browse the repository at this point in the history
…e already found
  • Loading branch information
sentriz committed Sep 16, 2021
1 parent b6e3d06 commit 04529b4
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions backend/importer/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,22 @@ type Importer struct {
}

func (i *Importer) ImportMedia(decoded *Decoded, timestamp time.Time, dirAlias, fileName string) error {
// insert media, thumbnail, and dir info, alert clients with update
id, isOld, err := i.importMedia(decoded.Filetype, decoded.Hash, decoded.Image, timestamp)
if err != nil {
return fmt.Errorf("import media with props: %w", err)
}
if err := i.importDirInfo(id, dirAlias, fileName); err != nil {
return fmt.Errorf("import dir info: %w", err)
}
if err := i.importThumbnail(id, decoded.Image); err != nil {
return fmt.Errorf("import thumbnail: %w", err)
}
i.Updates <- decoded.Hash

if isOld {
return nil
}

// insert blocks, alert clients with update
if err := i.importThumbnail(id, decoded.Image); err != nil {
return fmt.Errorf("import thumbnail: %w", err)
}
if err := i.importBlocks(id, decoded.Image); err != nil {
return fmt.Errorf("import blocks: %w", err)
}
Expand Down

0 comments on commit 04529b4

Please sign in to comment.