Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[videodb] Fix TV shows cleaning after 5755573981ca706a82a7ecbbdf5de112a570377a. #8133

Closed
wants to merge 1 commit into from

Conversation

anaconda
Copy link
Contributor

A regression in 5755573 meant removing a
deleted TV show needed multiple library cleanings (i.e. TV shows only got
removed when filesToTestForDelete was empty). This is much more noticeable
after 5cae3b5.

After 5755573:

  • if we had files to be checked for deletion: CleanMediaType would return a
    decision for the TV show path (delete) and a decision for the parent path
    (keep), so the TV show wasn't removed from the database;
  • if no files needed to be checked for deletion: CleanMediaType would return
    earlier and pathsDeleteDecisions was empty, so we'd have checked if the
    path existed and there was a decision for the parent path (delete) or no
    decision at all.

This commit checks if there's a decision to delete the parent path or it
exists (we only end up there if there's a decision to delete the path or it
doesn't exist), so that you can delete a TV show with episodes (or other random
files).

See:

The 2 booleans are just to improve readability.

@MartijnKaijser
Copy link
Member

@Montellese @mkortstiege ping

@mkortstiege
Copy link
Member

No objections but i'd like to get @Montellese opinion as well.

@MartijnKaijser
Copy link
Member

Ping

@mkortstiege mkortstiege added Type: Fix non-breaking change which fixes an issue v16 Jarvis Component: Database labels Oct 23, 2015
@mkortstiege
Copy link
Member

@Montellese could you please have a look at this?

"AND (exclude IS NULL OR exclude != 1))";
sql = "SELECT path.idPath, path.strPath, path.idParentPath, path2.strPath AS strParentPath "
"FROM path "
"LEFT JOIN path AS path2 ON path2.idPath = path.idParentPath "

This comment was marked as spam.

@anaconda
Copy link
Contributor Author

Please wait. This breaks multiple movies in the same folder:
http://forum.kodi.tv/showthread.php?tid=231092&pid=2142689#pid2142689

Suggestions welcome.

@anaconda
Copy link
Contributor Author

Looks like in that case pathsDeleteDecision->second is true and the added logic deletes it - why is it true (delete) if the path does exist?

Edit:

CleanDatabase: hasDecision=true pathsDeleteDecision->second=true
CleanDatabase: !CDirectory::Exists(/Users/anaconda/tmp/xbmc-testsource/Action/, false)=false
CleanDatabase: hasDecisionForParent=true pathsDeleteDecisionByParent->second=false
CleanDatabase: !parentPath.empty()=true CDirectory::Exists(/Users/anaconda/tmp/xbmc-testsource/, false)=true

@MartijnKaijser
Copy link
Member

@anaconda would this still something for Jarvis or too risky?

@anaconda
Copy link
Contributor Author

Too risky for Jarvis unless CleanMediaType is fixed to return false.
After a path with multiple movies is incorrectly cleaned, a subsequent scan adds them again, but you get duplicates.

A regression in 5755573 meant removing a
deleted TV show needed multiple library cleanings (i.e. TV shows only got
removed when filesToTestForDelete was empty).  This is much more noticeable
after 5cae3b5.

After 5755573:
  * if we had files to be checked for deletion: CleanMediaType would return a
    decision for the TV show path (delete) and a decision for the parent path
    (keep), so the TV show wasn't removed from the database;
  * if no files needed to be checked for deletion: CleanMediaType would return
    earlier and pathsDeleteDecisions was empty, so we'd have checked if the
    path existed and there was a decision for the parent path (delete) or no
    decision at all.

This commit checks if there's a decision to delete the parent path *or* it
exists (we only end up there if there's a decision to delete the path or it
doesn't exist), so that you can delete a TV show with episodes (or other random
files).

See:
  * http://forum.kodi.tv/showthread.php?tid=238881
@vbat99
Copy link

vbat99 commented Feb 22, 2016

No chance of this getting into 16.1 then?

@razzeee
Copy link
Member

razzeee commented Nov 14, 2016

@anaconda is this still wanted/needed?

@eusi
Copy link

eusi commented Apr 5, 2017

Actually your fix needs some improvements.

Example, I am using a movie structure like:
SourceVideoFolder ("Movies")
---QualityFolder (like "HD", "SD", "4k" etc.)
------YearFolder (like "1900-1999", "2000-2010" etc)
---------Movies

Following part of the if-statement (in VideoDatabase) wipes an entire folder (removes all movies in the folder from the database), when I delete only ONE movie in the folder and execute a "clean video library":
(pathsDeleteDecisionByParent != pathsDeleteDecisions.end() && pathsDeleteDecisionByParent->second)

This issue is super annoying for me and my folder structure. Because any time I delete a movie, like 200 movies getting removed as well from my kodi database.

It works correctly, if I change
if (scanSettings.parent_name) pathsDeleteDecisions.insert(std::make_pair(m_pDS2->fv(2).get_asInt(), del));
to
if (scanSettings.parent_name) pathsDeleteDecisions.insert(std::make_pair(m_pDS2->fv(2).get_asInt(), !CDirectory::Exists( parentPath, false ) && del));
Those line(s) can be found in CleanMediaType(). This method sets the pathsDeleteDecisionByParent-object.

@anaconda this could also be a fix for your last comment/worries on Oct 25, 2015.

I opened PR11937 that includes the fix and some of your/this improvements for better readability of this part.

@razzeee
Copy link
Member

razzeee commented Sep 16, 2017

@menakite will you revisit this?

@jenkins4kodi jenkins4kodi added the Rebase needed PR that does not apply/merge cleanly to current base branch label Nov 19, 2017
@jenkins4kodi
Copy link
Contributor

@anaconda this needs a rebase

@MartijnKaijser
Copy link
Member

I will close this PR. If there's interest please open a new one (with required changes if needed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Database Component: Video Rebase needed PR that does not apply/merge cleanly to current base branch Type: Fix non-breaking change which fixes an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants