|
|
|
@ -80,6 +80,8 @@ namespace NzbDrone.Core.MediaFiles
|
|
|
|
|
|
|
|
|
|
EnsureTrackFolder(trackFile, localTrack, filePath);
|
|
|
|
|
|
|
|
|
|
TryToCreateCueFile(localTrack, filePath);
|
|
|
|
|
|
|
|
|
|
_logger.Debug("Moving track file: {0} to {1}", trackFile.Path, filePath);
|
|
|
|
|
|
|
|
|
|
return TransferFile(trackFile, localTrack.Artist, localTrack.Tracks, filePath, TransferMode.Move);
|
|
|
|
@ -91,29 +93,34 @@ namespace NzbDrone.Core.MediaFiles
|
|
|
|
|
|
|
|
|
|
EnsureTrackFolder(trackFile, localTrack, filePath);
|
|
|
|
|
|
|
|
|
|
TryToCreateCueFile(localTrack, filePath);
|
|
|
|
|
|
|
|
|
|
if (_configService.CopyUsingHardlinks)
|
|
|
|
|
{
|
|
|
|
|
_logger.Debug("Attempting to hardlink track file: {0} to {1}", trackFile.Path, filePath);
|
|
|
|
|
return TransferFile(trackFile, localTrack.Artist, localTrack.Tracks, filePath, TransferMode.HardLinkOrCopy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.Debug("Copying track file: {0} to {1}", trackFile.Path, filePath);
|
|
|
|
|
return TransferFile(trackFile, localTrack.Artist, localTrack.Tracks, filePath, TransferMode.Copy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TryToCreateCueFile(LocalTrack localTrack, string trackFilePath)
|
|
|
|
|
{
|
|
|
|
|
if (localTrack.IsSingleFileRelease && !localTrack.CueSheetPath.Empty())
|
|
|
|
|
{
|
|
|
|
|
var directory = Path.GetDirectoryName(filePath);
|
|
|
|
|
var fileName = Path.GetFileNameWithoutExtension(filePath);
|
|
|
|
|
var directory = Path.GetDirectoryName(trackFilePath);
|
|
|
|
|
var fileName = Path.GetFileNameWithoutExtension(trackFilePath);
|
|
|
|
|
var cueSheetPath = Path.Combine(directory, fileName + ".cue");
|
|
|
|
|
_diskTransferService.TransferFile(localTrack.CueSheetPath, cueSheetPath, TransferMode.Copy);
|
|
|
|
|
_diskTransferService.TransferFile(localTrack.CueSheetPath, cueSheetPath, TransferMode.Copy, true);
|
|
|
|
|
var lines = new List<string>(File.ReadAllLines(cueSheetPath));
|
|
|
|
|
var fileLineIndex = lines.FindIndex(line => line.Contains("FILE"));
|
|
|
|
|
if (fileLineIndex != -1)
|
|
|
|
|
{
|
|
|
|
|
lines[fileLineIndex] = "FILE \"" + Path.GetFileName(filePath) + "\" WAVE";
|
|
|
|
|
lines[fileLineIndex] = "FILE \"" + Path.GetFileName(trackFilePath) + "\" WAVE";
|
|
|
|
|
File.WriteAllLines(cueSheetPath, lines);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_configService.CopyUsingHardlinks)
|
|
|
|
|
{
|
|
|
|
|
_logger.Debug("Attempting to hardlink track file: {0} to {1}", trackFile.Path, filePath);
|
|
|
|
|
return TransferFile(trackFile, localTrack.Artist, localTrack.Tracks, filePath, TransferMode.HardLinkOrCopy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_logger.Debug("Copying track file: {0} to {1}", trackFile.Path, filePath);
|
|
|
|
|
return TransferFile(trackFile, localTrack.Artist, localTrack.Tracks, filePath, TransferMode.Copy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private TrackFile TransferFile(TrackFile trackFile, Artist artist, List<Track> tracks, string destinationFilePath, TransferMode mode)
|
|
|
|
|