Skip to content

Commit

Permalink
Find inconsistent state: filter entries for the file but different pa…
Browse files Browse the repository at this point in the history
…th, fix #62
  • Loading branch information
rigon committed Feb 11, 2025
1 parent 3ab411b commit d3a2a12
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion server/album.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,16 @@ func (album *Album) GetPhotos(collection *Collection, runningInBackground bool,
}
}

// Find inconsistent state: filter entries for the file but different path
// TODO: modify the structure to make this case inheritably impossible
for i := len(photo.Files) - 1; i >= 0; i-- {
if photo.Files[i].Id == name && photo.Files[i].Path != fileDir {
photo.Files = append(photo.Files[:i], photo.Files[i+1:]...) // Remove
}
}

photoFile, err := photo.GetFile(name)
if err != nil || photoFile == nil || photoFile.Path != fileDir {
if err != nil || photoFile == nil {
photoFile = &File{
Path: fileDir,
Id: name,
Expand Down

0 comments on commit d3a2a12

Please sign in to comment.