Store the torrent name instead of the hash to the blackhole directory.
This commit is contained in:
parent
d01cb71866
commit
6ad51b036e
3 changed files with 24 additions and 8 deletions
|
|
@ -28,7 +28,7 @@ public static class DownloadHelper
|
||||||
|
|
||||||
fileName = HttpUtility.UrlDecode(fileName);
|
fileName = HttpUtility.UrlDecode(fileName);
|
||||||
|
|
||||||
fileName = RemoveInvalidFileNameChars(fileName);
|
fileName = FileHelper.RemoveInvalidFileNameChars(fileName);
|
||||||
|
|
||||||
var filePath = Path.Combine(torrentPath, fileName);
|
var filePath = Path.Combine(torrentPath, fileName);
|
||||||
|
|
||||||
|
|
@ -39,9 +39,4 @@ public static class DownloadHelper
|
||||||
{
|
{
|
||||||
return String.Concat(path.Split(Path.GetInvalidPathChars()));
|
return String.Concat(path.Split(Path.GetInvalidPathChars()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String RemoveInvalidFileNameChars(String filename)
|
|
||||||
{
|
|
||||||
return String.Concat(filename.Split(Path.GetInvalidFileNameChars()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -73,4 +73,9 @@ public static class FileHelper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String RemoveInvalidFileNameChars(String filename)
|
||||||
|
{
|
||||||
|
return String.Concat(filename.Split(Path.GetInvalidFileNameChars()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -142,7 +142,14 @@ public class Torrents
|
||||||
Directory.CreateDirectory(Settings.Get.General.CopyAddedTorrents);
|
Directory.CreateDirectory(Settings.Get.General.CopyAddedTorrents);
|
||||||
}
|
}
|
||||||
|
|
||||||
await File.WriteAllTextAsync(Path.Combine(Settings.Get.General.CopyAddedTorrents, $"{torrent.Hash}.magnet"), magnetLink);
|
var copyFileName = Path.Combine(Settings.Get.General.CopyAddedTorrents, $"{FileHelper.RemoveInvalidFileNameChars(magnet.Name)}.magnet");
|
||||||
|
|
||||||
|
if (File.Exists(copyFileName))
|
||||||
|
{
|
||||||
|
File.Delete(copyFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
await File.WriteAllTextAsync(copyFileName, magnetLink);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -175,6 +182,8 @@ public class Torrents
|
||||||
|
|
||||||
var newTorrent = await Add(id, hash, fileAsBase64, true, torrent);
|
var newTorrent = await Add(id, hash, fileAsBase64, true, torrent);
|
||||||
|
|
||||||
|
Log($"Adding {hash} torrent file", newTorrent);
|
||||||
|
|
||||||
if (!String.IsNullOrWhiteSpace(Settings.Get.General.CopyAddedTorrents))
|
if (!String.IsNullOrWhiteSpace(Settings.Get.General.CopyAddedTorrents))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -184,7 +193,14 @@ public class Torrents
|
||||||
Directory.CreateDirectory(Settings.Get.General.CopyAddedTorrents);
|
Directory.CreateDirectory(Settings.Get.General.CopyAddedTorrents);
|
||||||
}
|
}
|
||||||
|
|
||||||
await File.WriteAllBytesAsync(Path.Combine(Settings.Get.General.CopyAddedTorrents, $"{torrent.Hash}.torrent"), bytes);
|
var copyFileName = Path.Combine(Settings.Get.General.CopyAddedTorrents, $"{FileHelper.RemoveInvalidFileNameChars(monoTorrent.Name)}.torrent");
|
||||||
|
|
||||||
|
if (File.Exists(copyFileName))
|
||||||
|
{
|
||||||
|
File.Delete(copyFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
await File.WriteAllBytesAsync(copyFileName, bytes);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue