From 61e11471b3d91f4135313c567ce819a86b36a3b8 Mon Sep 17 00:00:00 2001 From: sentriz Date: Tue, 20 Apr 2021 22:25:12 +0100 Subject: [PATCH] Fix non-folder folder empty parent ids fixes #134 introduced by 711ffe144faaab42b3f0a1afc9d559ef02f77a3d id updated_at modified_at left_path right_path right_path_u_dec parent_id cover tag_artist_id tag_title tag_title_u_dec tag_brainz_id tag_year ---------- ----------------------------------- ----------------------------------- ---------- ---------- ---------------- ---------- ---------- ------------- ---------- --------------- ------------- ---------- 1 2021-04-20 22:04:31.437318349+01:00 2021-04-20 21:35:55.423563144+01:00 . 2 2021-04-20 22:04:31.437920005+01:00 2021-04-20 21:35:50.766896425+01:00 luke 3 2021-04-20 22:04:31.475871668+01:00 2021-04-20 21:35:11.526895985+01:00 luke/ (2003) Yos 2 folder.jpe 1 YosepH cf497d42-736a 2003 4 2021-04-20 22:04:31.476325505+01:00 2021-04-20 21:35:55.423563144+01:00 beng 5 2021-04-20 22:04:31.511647498+01:00 2021-04-20 21:35:27.060229492+01:00 beng/ (2013) Cha 4 folder.jpg 2 Chapter II bcafa993-f065 2013 -> id updated_at modified_at left_path right_path right_path_u_dec parent_id cover tag_artist_id tag_title tag_title_u_dec tag_brainz_id tag_year ---------- ----------------------------------- ----------------------------------- ---------- ---------- ---------------- ---------- ---------- ------------- ---------- --------------- ------------- ---------- 1 2021-04-20 22:22:55.368005558+01:00 2021-04-20 21:35:55.423563144+01:00 . 0 2 2021-04-20 22:22:55.331985959+01:00 2021-04-20 21:35:50.766896425+01:00 luke 1 0 3 2021-04-20 22:22:55.33148277+01:00 2021-04-20 21:35:11.526895985+01:00 luke/ (2003) Yos 2 folder.jpe 1 YosepH cf497d42-736a 2003 4 2021-04-20 22:22:55.367693081+01:00 2021-04-20 21:35:55.423563144+01:00 beng 1 0 5 2021-04-20 22:22:55.36711045+01:00 2021-04-20 21:35:27.060229492+01:00 beng/ (2013) Cha 4 folder.jpg 2 Chapter II bcafa993-f065 2013 --- server/db/model.go | 5 ++--- server/scanner/scanner.go | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/server/db/model.go b/server/db/model.go index 050e39e..4baad50 100644 --- a/server/db/model.go +++ b/server/db/model.go @@ -195,9 +195,8 @@ type Album struct { TagBrainzID string `sql:"default: null"` TagYear int `sql:"default: null"` Tracks []*Track - ChildCount int `sql:"-"` - Duration int `sql:"-"` - ShouldSave bool `sql:"-"` + ChildCount int `sql:"-"` + Duration int `sql:"-"` } func (a *Album) SID() *specid.ID { diff --git a/server/scanner/scanner.go b/server/scanner/scanner.go index 6ae0f44..648c5f7 100644 --- a/server/scanner/scanner.go +++ b/server/scanner/scanner.go @@ -324,7 +324,7 @@ func (s *Scanner) callbackPost(fullPath string, info *godirwalk.Dirent) error { // begin taking the current folder off the stack and add it's // parent, cover that we found, etc. folder := s.curFolders.Pop() - if !folder.ShouldSave { + if folder.ParentID != 0 { return nil } folder.ParentID = s.curFolders.PeekID() @@ -477,7 +477,7 @@ func (s *Scanner) handleTrack(it *item) error { // ** begin set album if this is the first track in the folder folder := s.curFolders.Peek() - if folder.ShouldSave { + if folder.TagTitle != "" { return nil } err = s.trTx. @@ -501,7 +501,6 @@ func (s *Scanner) handleTrack(it *item) error { folder.TagBrainzID = trTags.AlbumBrainzID() folder.TagYear = trTags.Year() folder.TagArtistID = artist.ID - folder.ShouldSave = true return nil }