Permalink
Browse files

When MyList ID is missing add file first then update the state, shoul…

…d fix issue #748
  • Loading branch information...
hidden4003 committed Jul 18, 2018
1 parent 6118075 commit ca967228a43405d5f4f4fe9795ddc8b8badb7e59
Showing with 15 additions and 11 deletions.
  1. +15 −11 Shoko.Server/AniDBHelper.cs
@@ -543,6 +543,20 @@ public void UpdateMyListFileStatus(IHash hash, bool watched, DateTime? watchedDa
if (watched && watchedDate == null) watchedDate = DateTime.Now;

enHelperActivityType ev;
if (hash.MyListID == 0)
{
logger.Trace($"File has no MyListID, attempting to add: {hash.ED2KHash}");
// Run sychronously, but still do all of the stuff with watched state settings
CommandRequest_AddFileToMyList addcmd = new CommandRequest_AddFileToMyList(hash.ED2KHash);
// Initialize private parts
addcmd.LoadFromDBCommand(addcmd.ToDatabaseObject());
addcmd.ProcessCommand();

SVR_VideoLocal vid = RepoFactory.VideoLocal.GetByHash(hash.ED2KHash);
if (vid == null) return;
hash.MyListID = vid.MyListID;
}

if (hash.MyListID > 0)
{
cmdUpdateFile.Init(hash, watched, watchedDate);
@@ -553,17 +567,7 @@ public void UpdateMyListFileStatus(IHash hash, bool watched, DateTime? watchedDa
}
else
{
logger.Trace($"File has no MyListID, attempting to add: {hash.ED2KHash}");
ev = enHelperActivityType.NoSuchMyListFile;
}

if (ev == enHelperActivityType.NoSuchMyListFile)
{
// Run sychronously, but still do all of the stuff with watched state settings
CommandRequest_AddFileToMyList addcmd = new CommandRequest_AddFileToMyList(hash.ED2KHash);
// Initialize private parts
addcmd.LoadFromDBCommand(addcmd.ToDatabaseObject());
addcmd.ProcessCommand();
logger.Trace($"File still has no MyListID: {hash.ED2KHash}");
}
}
}

1 comment on commit ca96722

@da3dsoul

This comment has been minimized.

Member

da3dsoul commented on ca96722 Jul 18, 2018

I had it in else because adding the file will update its state. Was there an issue with it?

Please sign in to comment.