Skip to content

Commit

Permalink
fix: don't attempt to rename if import folder is
Browse files Browse the repository at this point in the history
unavailable or if it not a drop source or drop destination.
  • Loading branch information
revam committed Aug 25, 2024
1 parent c14033a commit 05312f5
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Shoko.Server/Renamer/RenameFileService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -47,6 +47,25 @@ public RelocationResult GetNewPath(SVR_VideoLocal_Place place, RenamerConfig? re
var shouldMove = move ?? settings.Plugins.Renamer.MoveOnImport;
var shouldRename = rename ?? settings.Plugins.Renamer.RenameOnImport;

// Make sure the import folder is reachable.
var importFolder = place.ImportFolder;
if (importFolder is null)
return new()
{
Success = false,
ShouldRetry = false,
ErrorMessage = $"Unable to find import folder for file with ID {place.VideoLocal}.",
};

// If we try to run on a file that's not in a drop source or destination, then fail.
if (importFolder.IsDropSource == 0 && importFolder.IsDropDestination == 0)
return new()
{
Success = false,
ShouldRetry = false,
ErrorMessage = "Not relocating file as it is not in a drop source or drop destination.",
};

var videoLocal = place.VideoLocal ??
throw new NullReferenceException(nameof(place.VideoLocal));
var xrefs = videoLocal.EpisodeCrossRefs;
Expand Down

0 comments on commit 05312f5

Please sign in to comment.