Style fixes.
This commit is contained in:
parent
e5dfb0e027
commit
c21d578a23
13 changed files with 72 additions and 83 deletions
|
|
@ -269,7 +269,7 @@ public class DownloadData(DataContext dataContext)
|
||||||
{
|
{
|
||||||
var dbDownload = await dataContext.Downloads
|
var dbDownload = await dataContext.Downloads
|
||||||
.FirstOrDefaultAsync(m => m.DownloadId == downloadId)
|
.FirstOrDefaultAsync(m => m.DownloadId == downloadId)
|
||||||
?? throw new Exception($"Cannot find download with ID {downloadId}");
|
?? throw new($"Cannot find download with ID {downloadId}");
|
||||||
|
|
||||||
dbDownload.RetryCount = 0;
|
dbDownload.RetryCount = 0;
|
||||||
dbDownload.Link = null;
|
dbDownload.Link = null;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace RdtClient.Data.Data;
|
||||||
|
|
||||||
public class SettingData(DataContext dataContext, ILogger<SettingData> logger)
|
public class SettingData(DataContext dataContext, ILogger<SettingData> logger)
|
||||||
{
|
{
|
||||||
public static DbSettings Get { get; } = new DbSettings();
|
public static DbSettings Get { get; } = new();
|
||||||
|
|
||||||
public static IList<SettingProperty> GetAll()
|
public static IList<SettingProperty> GetAll()
|
||||||
{
|
{
|
||||||
|
|
@ -57,7 +57,7 @@ public class SettingData(DataContext dataContext, ILogger<SettingData> logger)
|
||||||
|
|
||||||
if (settings.Count == 0)
|
if (settings.Count == 0)
|
||||||
{
|
{
|
||||||
throw new Exception("No settings found, please restart");
|
throw new("No settings found, please restart");
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSettings(settings, Get, null);
|
SetSettings(settings, Get, null);
|
||||||
|
|
@ -124,7 +124,7 @@ public class SettingData(DataContext dataContext, ILogger<SettingData> logger)
|
||||||
if (property.PropertyType.IsEnum)
|
if (property.PropertyType.IsEnum)
|
||||||
{
|
{
|
||||||
settingProperty.Type = "Enum";
|
settingProperty.Type = "Enum";
|
||||||
settingProperty.EnumValues = new Dictionary<Int32, String>();
|
settingProperty.EnumValues = new();
|
||||||
|
|
||||||
foreach (var e in Enum.GetValues(property.PropertyType).Cast<Enum>())
|
foreach (var e in Enum.GetValues(property.PropertyType).Cast<Enum>())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public class DownloadClient(Download download, Torrent torrent, String destinati
|
||||||
{
|
{
|
||||||
if (download.Link == null)
|
if (download.Link == null)
|
||||||
{
|
{
|
||||||
throw new Exception($"Invalid download link");
|
throw new($"Invalid download link");
|
||||||
}
|
}
|
||||||
|
|
||||||
var filePath = DownloadHelper.GetDownloadPath(destinationPath, torrent, download);
|
var filePath = DownloadHelper.GetDownloadPath(destinationPath, torrent, download);
|
||||||
|
|
@ -36,7 +36,7 @@ public class DownloadClient(Download download, Torrent torrent, String destinati
|
||||||
|
|
||||||
if (filePath == null || downloadPath == null)
|
if (filePath == null || downloadPath == null)
|
||||||
{
|
{
|
||||||
throw new Exception("Invalid download path");
|
throw new("Invalid download path");
|
||||||
}
|
}
|
||||||
|
|
||||||
await FileHelper.Delete(filePath);
|
await FileHelper.Delete(filePath);
|
||||||
|
|
@ -49,7 +49,7 @@ public class DownloadClient(Download download, Torrent torrent, String destinati
|
||||||
Data.Enums.DownloadClient.Bezzad => new BezzadDownloader(download.Link, filePath),
|
Data.Enums.DownloadClient.Bezzad => new BezzadDownloader(download.Link, filePath),
|
||||||
Data.Enums.DownloadClient.Aria2c => new Aria2cDownloader(download.RemoteId, download.Link, filePath, downloadPath),
|
Data.Enums.DownloadClient.Aria2c => new Aria2cDownloader(download.RemoteId, download.Link, filePath, downloadPath),
|
||||||
Data.Enums.DownloadClient.Symlink => new SymlinkDownloader(download.Link, filePath),
|
Data.Enums.DownloadClient.Symlink => new SymlinkDownloader(download.Link, filePath),
|
||||||
_ => throw new Exception($"Unknown download client {Settings.Get.DownloadClient}")
|
_ => throw new($"Unknown download client {Settings.Get.DownloadClient}")
|
||||||
};
|
};
|
||||||
|
|
||||||
Downloader.DownloadComplete += (_, args) =>
|
Downloader.DownloadComplete += (_, args) =>
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,12 @@ public class Aria2cDownloader : IDownloader
|
||||||
Timeout = TimeSpan.FromSeconds(10)
|
Timeout = TimeSpan.FromSeconds(10)
|
||||||
};
|
};
|
||||||
|
|
||||||
_aria2NetClient = new Aria2NetClient(Settings.Get.DownloadClient.Aria2cUrl, Settings.Get.DownloadClient.Aria2cSecret, httpClient, 10);
|
_aria2NetClient = new(Settings.Get.DownloadClient.Aria2cUrl, Settings.Get.DownloadClient.Aria2cSecret, httpClient, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<String> Download()
|
public async Task<String> Download()
|
||||||
{
|
{
|
||||||
var path = Path.GetDirectoryName(_remotePath) ?? throw new Exception($"Invalid file path {_filePath}");
|
var path = Path.GetDirectoryName(_remotePath) ?? throw new($"Invalid file path {_filePath}");
|
||||||
var fileName = Path.GetFileName(_filePath);
|
var fileName = Path.GetFileName(_filePath);
|
||||||
|
|
||||||
_logger.Debug($"Starting download of {_uri}, writing to path: {_filePath} (on aria2: {_remotePath}), fileName: {fileName}");
|
_logger.Debug($"Starting download of {_uri}, writing to path: {_filePath} (on aria2: {_remotePath}), fileName: {fileName}");
|
||||||
|
|
@ -58,7 +58,7 @@ public class Aria2cDownloader : IDownloader
|
||||||
|
|
||||||
if (isAlreadyAdded)
|
if (isAlreadyAdded)
|
||||||
{
|
{
|
||||||
throw new Exception($"The download link {_uri} has already been added to Aria2");
|
throw new($"The download link {_uri} has already been added to Aria2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,7 +172,7 @@ public class Aria2cDownloader : IDownloader
|
||||||
|
|
||||||
if (download == null)
|
if (download == null)
|
||||||
{
|
{
|
||||||
DownloadComplete?.Invoke(this, new DownloadCompleteEventArgs
|
DownloadComplete?.Invoke(this, new()
|
||||||
{
|
{
|
||||||
Error = $"Download was not found in Aria2"
|
Error = $"Download was not found in Aria2"
|
||||||
});
|
});
|
||||||
|
|
@ -182,7 +182,7 @@ public class Aria2cDownloader : IDownloader
|
||||||
if (!String.IsNullOrWhiteSpace(download.ErrorMessage) || download.Status == "error")
|
if (!String.IsNullOrWhiteSpace(download.ErrorMessage) || download.Status == "error")
|
||||||
{
|
{
|
||||||
await Remove();
|
await Remove();
|
||||||
DownloadComplete?.Invoke(this, new DownloadCompleteEventArgs
|
DownloadComplete?.Invoke(this, new()
|
||||||
{
|
{
|
||||||
Error = $"{download.ErrorCode}: {download.ErrorMessage}"
|
Error = $"{download.ErrorCode}: {download.ErrorMessage}"
|
||||||
});
|
});
|
||||||
|
|
@ -200,7 +200,7 @@ public class Aria2cDownloader : IDownloader
|
||||||
{
|
{
|
||||||
if (retryCount >= 10)
|
if (retryCount >= 10)
|
||||||
{
|
{
|
||||||
DownloadComplete?.Invoke(this, new DownloadCompleteEventArgs
|
DownloadComplete?.Invoke(this, new()
|
||||||
{
|
{
|
||||||
Error = $"File not found at {_filePath} (on aria2 {_remotePath})"
|
Error = $"File not found at {_filePath} (on aria2 {_remotePath})"
|
||||||
});
|
});
|
||||||
|
|
@ -209,7 +209,7 @@ public class Aria2cDownloader : IDownloader
|
||||||
|
|
||||||
if (File.Exists(_filePath))
|
if (File.Exists(_filePath))
|
||||||
{
|
{
|
||||||
DownloadComplete?.Invoke(this, new DownloadCompleteEventArgs());
|
DownloadComplete?.Invoke(this, new());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -219,7 +219,7 @@ public class Aria2cDownloader : IDownloader
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadProgress?.Invoke(this, new DownloadProgressEventArgs
|
DownloadProgress?.Invoke(this, new()
|
||||||
{
|
{
|
||||||
BytesDone = download.CompletedLength,
|
BytesDone = download.CompletedLength,
|
||||||
BytesTotal = download.TotalLength,
|
BytesTotal = download.TotalLength,
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ public class BezzadDownloader : IDownloader
|
||||||
var settingProxyServer = Settings.Get.DownloadClient.ProxyServer;
|
var settingProxyServer = Settings.Get.DownloadClient.ProxyServer;
|
||||||
|
|
||||||
// For all options, see https://github.com/bezzad/Downloader
|
// For all options, see https://github.com/bezzad/Downloader
|
||||||
_downloadConfiguration = new DownloadConfiguration
|
_downloadConfiguration = new()
|
||||||
{
|
{
|
||||||
MaxTryAgainOnFailover = 5,
|
MaxTryAgainOnFailover = 5,
|
||||||
RangeDownload = false,
|
RangeDownload = false,
|
||||||
|
|
@ -56,7 +56,7 @@ public class BezzadDownloader : IDownloader
|
||||||
_downloadConfiguration.RequestConfiguration.Proxy = new WebProxy(new Uri(settingProxyServer), false);
|
_downloadConfiguration.RequestConfiguration.Proxy = new WebProxy(new Uri(settingProxyServer), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
_downloadService = new DownloadService(_downloadConfiguration);
|
_downloadService = new(_downloadConfiguration);
|
||||||
|
|
||||||
_downloadService.DownloadProgressChanged += (_, args) =>
|
_downloadService.DownloadProgressChanged += (_, args) =>
|
||||||
{
|
{
|
||||||
|
|
@ -66,7 +66,7 @@ public class BezzadDownloader : IDownloader
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadProgress.Invoke(this,
|
DownloadProgress.Invoke(this,
|
||||||
new DownloadProgressEventArgs
|
new()
|
||||||
{
|
{
|
||||||
Speed = (Int64)args.BytesPerSecondSpeed,
|
Speed = (Int64)args.BytesPerSecondSpeed,
|
||||||
BytesDone = args.ReceivedBytesSize,
|
BytesDone = args.ReceivedBytesSize,
|
||||||
|
|
@ -88,7 +88,7 @@ public class BezzadDownloader : IDownloader
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadComplete?.Invoke(this,
|
DownloadComplete?.Invoke(this,
|
||||||
new DownloadCompleteEventArgs
|
new()
|
||||||
{
|
{
|
||||||
Error = error
|
Error = error
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,11 @@ public class InternalDownloader : IDownloader
|
||||||
_uri = uri;
|
_uri = uri;
|
||||||
_filePath = filePath;
|
_filePath = filePath;
|
||||||
|
|
||||||
_downloadConfiguration = new DownloaderNET.Settings();
|
_downloadConfiguration = new();
|
||||||
|
|
||||||
SetSettings();
|
SetSettings();
|
||||||
|
|
||||||
_downloadService = new DownloaderNET.Downloader(_uri, _filePath, _downloadConfiguration);
|
_downloadService = new(_uri, _filePath, _downloadConfiguration);
|
||||||
|
|
||||||
//_downloadService.OnLog += message => Debug.WriteLine(message.Message);
|
//_downloadService.OnLog += message => Debug.WriteLine(message.Message);
|
||||||
|
|
||||||
|
|
@ -43,7 +43,7 @@ public class InternalDownloader : IDownloader
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadProgress.Invoke(this,
|
DownloadProgress.Invoke(this,
|
||||||
new DownloadProgressEventArgs
|
new()
|
||||||
{
|
{
|
||||||
Speed = (Int64)chunks.Where(m => m.IsActive).Sum(m => m.Speed),
|
Speed = (Int64)chunks.Where(m => m.IsActive).Sum(m => m.Speed),
|
||||||
BytesDone = chunks.Sum(m => m.DownloadBytes),
|
BytesDone = chunks.Sum(m => m.DownloadBytes),
|
||||||
|
|
@ -54,7 +54,7 @@ public class InternalDownloader : IDownloader
|
||||||
_downloadService.OnComplete += (_, error) =>
|
_downloadService.OnComplete += (_, error) =>
|
||||||
{
|
{
|
||||||
DownloadComplete?.Invoke(this,
|
DownloadComplete?.Invoke(this,
|
||||||
new DownloadCompleteEventArgs
|
new()
|
||||||
{
|
{
|
||||||
Error = error?.Message
|
Error = error?.Message
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ public class QBittorrent(ILogger<QBittorrent> logger, Settings settings, Authent
|
||||||
SavePath = "",
|
SavePath = "",
|
||||||
SavePathChangedTmmEnabled = false,
|
SavePathChangedTmmEnabled = false,
|
||||||
SaveResumeDataInterval = 60,
|
SaveResumeDataInterval = 60,
|
||||||
ScanDirs = new ScanDirs(),
|
ScanDirs = new(),
|
||||||
ScheduleFromHour = 8,
|
ScheduleFromHour = 8,
|
||||||
ScheduleFromMin = 0,
|
ScheduleFromMin = 0,
|
||||||
ScheduleToHour = 20,
|
ScheduleToHour = 20,
|
||||||
|
|
@ -190,13 +190,13 @@ public class QBittorrent(ILogger<QBittorrent> logger, Settings settings, Authent
|
||||||
|
|
||||||
var results = new List<TorrentInfo>();
|
var results = new List<TorrentInfo>();
|
||||||
|
|
||||||
var torrents1 = await torrents.Get();
|
var allTorrents = await torrents.Get();
|
||||||
|
|
||||||
var prio = 0;
|
var prio = 0;
|
||||||
|
|
||||||
Decimal? downloadProgress = 0;
|
Decimal? downloadProgress = 0;
|
||||||
|
|
||||||
foreach (var torrent in torrents1)
|
foreach (var torrent in allTorrents)
|
||||||
{
|
{
|
||||||
var downloadPath = savePath;
|
var downloadPath = savePath;
|
||||||
|
|
||||||
|
|
@ -485,9 +485,9 @@ public class QBittorrent(ILogger<QBittorrent> logger, Settings settings, Authent
|
||||||
|
|
||||||
public async Task<IDictionary<String, TorrentCategory>> TorrentsCategories()
|
public async Task<IDictionary<String, TorrentCategory>> TorrentsCategories()
|
||||||
{
|
{
|
||||||
var torrents1 = await torrents.Get();
|
var allTorrents = await torrents.Get();
|
||||||
|
|
||||||
var torrentsToGroup = torrents1.Where(m => !String.IsNullOrWhiteSpace(m.Category))
|
var torrentsToGroup = allTorrents.Where(m => !String.IsNullOrWhiteSpace(m.Category))
|
||||||
.Select(m => m.Category!.ToLower())
|
.Select(m => m.Category!.ToLower())
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
|
@ -580,9 +580,9 @@ public class QBittorrent(ILogger<QBittorrent> logger, Settings settings, Authent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var downloads1 = await downloads.GetForTorrent(torrent.TorrentId);
|
var downloadsForTorrent = await downloads.GetForTorrent(torrent.TorrentId);
|
||||||
|
|
||||||
foreach (var download in downloads1)
|
foreach (var download in downloadsForTorrent)
|
||||||
{
|
{
|
||||||
if (TorrentRunner.ActiveDownloadClients.TryGetValue(download.DownloadId, out var downloadClient))
|
if (TorrentRunner.ActiveDownloadClients.TryGetValue(download.DownloadId, out var downloadClient))
|
||||||
{
|
{
|
||||||
|
|
@ -600,9 +600,9 @@ public class QBittorrent(ILogger<QBittorrent> logger, Settings settings, Authent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var downloads1 = await downloads.GetForTorrent(torrent.TorrentId);
|
var downloadsForTorrent = await downloads.GetForTorrent(torrent.TorrentId);
|
||||||
|
|
||||||
foreach (var download in downloads1)
|
foreach (var download in downloadsForTorrent)
|
||||||
{
|
{
|
||||||
if (TorrentRunner.ActiveDownloadClients.TryGetValue(download.DownloadId, out var downloadClient))
|
if (TorrentRunner.ActiveDownloadClients.TryGetValue(download.DownloadId, out var downloadClient))
|
||||||
{
|
{
|
||||||
|
|
@ -619,7 +619,7 @@ public class QBittorrent(ILogger<QBittorrent> logger, Settings settings, Authent
|
||||||
|
|
||||||
var activeDownloads = TorrentRunner.ActiveDownloadClients.Sum(m => m.Value.Speed);
|
var activeDownloads = TorrentRunner.ActiveDownloadClients.Sum(m => m.Value.Speed);
|
||||||
|
|
||||||
return new SyncMetaData
|
return new()
|
||||||
{
|
{
|
||||||
Categories = categories,
|
Categories = categories,
|
||||||
FullUpdate = true,
|
FullUpdate = true,
|
||||||
|
|
@ -627,7 +627,7 @@ public class QBittorrent(ILogger<QBittorrent> logger, Settings settings, Authent
|
||||||
Tags = null,
|
Tags = null,
|
||||||
Trackers = new Dictionary<String, List<String>>(),
|
Trackers = new Dictionary<String, List<String>>(),
|
||||||
Torrents = torrents.ToDictionary(m => m.Hash, m => m),
|
Torrents = torrents.ToDictionary(m => m.Hash, m => m),
|
||||||
ServerState = new SyncMetaDataServerState
|
ServerState = new()
|
||||||
{
|
{
|
||||||
DlInfoSpeed = activeDownloads,
|
DlInfoSpeed = activeDownloads,
|
||||||
UpInfoSpeed = 0
|
UpInfoSpeed = 0
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,17 @@ public class RemoteService(IHubContext<RdtHub> hub, Torrents torrents)
|
||||||
{
|
{
|
||||||
public async Task Update()
|
public async Task Update()
|
||||||
{
|
{
|
||||||
var torrents1 = await torrents.Get();
|
var allTorrents = await torrents.Get();
|
||||||
|
|
||||||
// Prevent infinite recursion when serializing
|
// Prevent infinite recursion when serializing
|
||||||
foreach (var file in torrents1.SelectMany(torrent => torrent.Downloads))
|
foreach (var file in allTorrents.SelectMany(torrent => torrent.Downloads))
|
||||||
{
|
{
|
||||||
file.Torrent = null;
|
file.Torrent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
await hub.Clients.All.SendCoreAsync("update",
|
await hub.Clients.All.SendCoreAsync("update",
|
||||||
new Object[]
|
[
|
||||||
{
|
allTorrents
|
||||||
torrents1
|
]);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -20,7 +20,7 @@ public class RealDebridTorrentClient(ILogger<RealDebridTorrentClient> logger, IH
|
||||||
|
|
||||||
if (String.IsNullOrWhiteSpace(apiKey))
|
if (String.IsNullOrWhiteSpace(apiKey))
|
||||||
{
|
{
|
||||||
throw new Exception("Real-Debrid API Key not set in the settings");
|
throw new("Real-Debrid API Key not set in the settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
var httpClient = httpClientFactory.CreateClient();
|
var httpClient = httpClientFactory.CreateClient();
|
||||||
|
|
@ -63,7 +63,7 @@ public class RealDebridTorrentClient(ILogger<RealDebridTorrentClient> logger, IH
|
||||||
|
|
||||||
private TorrentClientTorrent Map(Torrent torrent)
|
private TorrentClientTorrent Map(Torrent torrent)
|
||||||
{
|
{
|
||||||
return new TorrentClientTorrent
|
return new()
|
||||||
{
|
{
|
||||||
Id = torrent.Id,
|
Id = torrent.Id,
|
||||||
Filename = torrent.Filename,
|
Filename = torrent.Filename,
|
||||||
|
|
@ -116,7 +116,7 @@ public class RealDebridTorrentClient(ILogger<RealDebridTorrentClient> logger, IH
|
||||||
{
|
{
|
||||||
var user = await GetClient().User.GetAsync();
|
var user = await GetClient().User.GetAsync();
|
||||||
|
|
||||||
return new TorrentClientUser
|
return new()
|
||||||
{
|
{
|
||||||
Username = user.Username,
|
Username = user.Username,
|
||||||
Expiration = user.Premium > 0 ? user.Expiration : null
|
Expiration = user.Premium > 0 ? user.Expiration : null
|
||||||
|
|
@ -272,7 +272,7 @@ public class RealDebridTorrentClient(ILogger<RealDebridTorrentClient> logger, IH
|
||||||
|
|
||||||
if (result.Download == null)
|
if (result.Download == null)
|
||||||
{
|
{
|
||||||
throw new Exception($"Unrestrict returned an invalid download");
|
throw new($"Unrestrict returned an invalid download");
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.Download;
|
return result.Download;
|
||||||
|
|
@ -287,7 +287,7 @@ public class RealDebridTorrentClient(ILogger<RealDebridTorrentClient> logger, IH
|
||||||
return torrent;
|
return torrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rdTorrent = await GetInfo(torrent.RdId) ?? throw new Exception($"Resource not found");
|
var rdTorrent = await GetInfo(torrent.RdId) ?? throw new($"Resource not found");
|
||||||
|
|
||||||
if (!String.IsNullOrWhiteSpace(rdTorrent.Filename))
|
if (!String.IsNullOrWhiteSpace(rdTorrent.Filename))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,11 @@ public class Torrents(
|
||||||
{
|
{
|
||||||
private static readonly SemaphoreSlim RealDebridUpdateLock = new(1, 1);
|
private static readonly SemaphoreSlim RealDebridUpdateLock = new(1, 1);
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions JsonSerializerOptions = new()
|
||||||
|
{
|
||||||
|
ReferenceHandler = ReferenceHandler.IgnoreCycles
|
||||||
|
};
|
||||||
|
|
||||||
private ITorrentClient TorrentClient
|
private ITorrentClient TorrentClient
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -35,7 +40,7 @@ public class Torrents(
|
||||||
Provider.Premiumize => premiumizeTorrentClient,
|
Provider.Premiumize => premiumizeTorrentClient,
|
||||||
Provider.RealDebrid => realDebridTorrentClient,
|
Provider.RealDebrid => realDebridTorrentClient,
|
||||||
Provider.AllDebrid => allDebridTorrentClient,
|
Provider.AllDebrid => allDebridTorrentClient,
|
||||||
_ => throw new Exception("Invalid Provider")
|
_ => throw new("Invalid Provider")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -105,7 +110,7 @@ public class Torrents(
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.LogError(ex, "{ex.Message}, trying to parse {magnetLink}", ex.Message, magnetLink);
|
logger.LogError(ex, "{ex.Message}, trying to parse {magnetLink}", ex.Message, magnetLink);
|
||||||
throw new Exception($"{ex.Message}, trying to parse {magnetLink}");
|
throw new($"{ex.Message}, trying to parse {magnetLink}");
|
||||||
}
|
}
|
||||||
|
|
||||||
var id = await TorrentClient.AddMagnet(magnetLink);
|
var id = await TorrentClient.AddMagnet(magnetLink);
|
||||||
|
|
@ -156,7 +161,7 @@ public class Torrents(
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
throw new Exception($"{ex.Message}, trying to parse {fileAsBase64}");
|
throw new($"{ex.Message}, trying to parse {fileAsBase64}");
|
||||||
}
|
}
|
||||||
|
|
||||||
var id = await TorrentClient.AddFile(bytes);
|
var id = await TorrentClient.AddFile(bytes);
|
||||||
|
|
@ -352,12 +357,7 @@ public class Torrents(
|
||||||
|
|
||||||
public async Task<String> UnrestrictLink(Guid downloadId)
|
public async Task<String> UnrestrictLink(Guid downloadId)
|
||||||
{
|
{
|
||||||
var download = await downloads.GetById(downloadId);
|
var download = await downloads.GetById(downloadId) ?? throw new($"Download with ID {downloadId} not found");
|
||||||
|
|
||||||
if (download == null)
|
|
||||||
{
|
|
||||||
throw new Exception($"Download with ID {downloadId} not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
Log($"Unrestricting link", download, download.Torrent);
|
Log($"Unrestricting link", download, download.Torrent);
|
||||||
|
|
||||||
|
|
@ -494,7 +494,7 @@ public class Torrents(
|
||||||
|
|
||||||
if (String.IsNullOrWhiteSpace(torrent.FileOrMagnet))
|
if (String.IsNullOrWhiteSpace(torrent.FileOrMagnet))
|
||||||
{
|
{
|
||||||
throw new Exception($"Cannot re-add this torrent, original magnet or file not found");
|
throw new($"Cannot re-add this torrent, original magnet or file not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
Torrent newTorrent;
|
Torrent newTorrent;
|
||||||
|
|
@ -681,14 +681,9 @@ public class Torrents(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var torrent = await torrentData.GetById(torrentId);
|
var torrent = await torrentData.GetById(torrentId) ?? throw new($"Cannot find Torrent with ID {torrentId}");
|
||||||
|
|
||||||
if (torrent == null)
|
var downloadsForTorrent = await downloads.GetForTorrent(torrentId);
|
||||||
{
|
|
||||||
throw new Exception($"Cannot find Torrent with ID {torrentId}");
|
|
||||||
}
|
|
||||||
|
|
||||||
var downloads1 = await downloads.GetForTorrent(torrentId);
|
|
||||||
|
|
||||||
var fileName = Settings.Get.General.RunOnTorrentCompleteFileName;
|
var fileName = Settings.Get.General.RunOnTorrentCompleteFileName;
|
||||||
var arguments = Settings.Get.General.RunOnTorrentCompleteArguments ?? "";
|
var arguments = Settings.Get.General.RunOnTorrentCompleteArguments ?? "";
|
||||||
|
|
@ -712,7 +707,7 @@ public class Torrents(
|
||||||
arguments = arguments.Replace("%F", $"\"{filePath}\"");
|
arguments = arguments.Replace("%F", $"\"{filePath}\"");
|
||||||
arguments = arguments.Replace("%R", $"\"{downloadPath}\"");
|
arguments = arguments.Replace("%R", $"\"{downloadPath}\"");
|
||||||
arguments = arguments.Replace("%D", $"\"{torrentPath}\"");
|
arguments = arguments.Replace("%D", $"\"{torrentPath}\"");
|
||||||
arguments = arguments.Replace("%C", downloads1.Count.ToString(CultureInfo.InvariantCulture).Replace(",", "").Replace(".", ""));
|
arguments = arguments.Replace("%C", downloadsForTorrent.Count.ToString(CultureInfo.InvariantCulture).Replace(",", "").Replace(".", ""));
|
||||||
arguments = arguments.Replace("%Z", torrent.RdSize?.ToString(CultureInfo.InvariantCulture).Replace(",", "").Replace(".", ""));
|
arguments = arguments.Replace("%Z", torrent.RdSize?.ToString(CultureInfo.InvariantCulture).Replace(",", "").Replace(".", ""));
|
||||||
arguments = arguments.Replace("%I", torrent.Hash);
|
arguments = arguments.Replace("%I", torrent.Hash);
|
||||||
|
|
||||||
|
|
@ -778,19 +773,11 @@ public class Torrents(
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var originalTorrent = JsonSerializer.Serialize(torrent,
|
var originalTorrent = JsonSerializer.Serialize(torrent, JsonSerializerOptions);
|
||||||
new JsonSerializerOptions
|
|
||||||
{
|
|
||||||
ReferenceHandler = ReferenceHandler.IgnoreCycles
|
|
||||||
});
|
|
||||||
|
|
||||||
await TorrentClient.UpdateData(torrent, torrentClientTorrent);
|
await TorrentClient.UpdateData(torrent, torrentClientTorrent);
|
||||||
|
|
||||||
var newTorrent = JsonSerializer.Serialize(torrent,
|
var newTorrent = JsonSerializer.Serialize(torrent, JsonSerializerOptions);
|
||||||
new JsonSerializerOptions
|
|
||||||
{
|
|
||||||
ReferenceHandler = ReferenceHandler.IgnoreCycles
|
|
||||||
});
|
|
||||||
|
|
||||||
if (originalTorrent != newTorrent)
|
if (originalTorrent != newTorrent)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@ public class UnpackClient(Download download, String destinationPath)
|
||||||
|
|
||||||
public Int32 Progess { get; private set; }
|
public Int32 Progess { get; private set; }
|
||||||
|
|
||||||
private readonly Torrent _torrent = download.Torrent ?? throw new Exception($"Torrent is null");
|
private readonly Torrent _torrent = download.Torrent ?? throw new($"Torrent is null");
|
||||||
|
|
||||||
private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
|
private readonly CancellationTokenSource _cancellationTokenSource = new();
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
|
|
@ -25,12 +25,7 @@ public class UnpackClient(Download download, String destinationPath)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var filePath = DownloadHelper.GetDownloadPath(destinationPath, _torrent, download);
|
var filePath = DownloadHelper.GetDownloadPath(destinationPath, _torrent, download) ?? throw new("Invalid download path");
|
||||||
|
|
||||||
if (filePath == null)
|
|
||||||
{
|
|
||||||
throw new Exception("Invalid download path");
|
|
||||||
}
|
|
||||||
|
|
||||||
Task.Run(async delegate
|
Task.Run(async delegate
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ public class SettingsController(Settings settings, Torrents torrents) : Controll
|
||||||
|
|
||||||
if (!Directory.Exists(path))
|
if (!Directory.Exists(path))
|
||||||
{
|
{
|
||||||
throw new Exception($"Path {path} does not exist");
|
throw new($"Path {path} does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
var testFile = $"{path}/test.txt";
|
var testFile = $"{path}/test.txt";
|
||||||
|
|
@ -88,7 +88,7 @@ public class SettingsController(Settings settings, Torrents torrents) : Controll
|
||||||
var download = new Download
|
var download = new Download
|
||||||
{
|
{
|
||||||
Link = "https://34.download.real-debrid.com/speedtest/testDefault.rar",
|
Link = "https://34.download.real-debrid.com/speedtest/testDefault.rar",
|
||||||
Torrent = new Torrent
|
Torrent = new()
|
||||||
{
|
{
|
||||||
RdName = ""
|
RdName = ""
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
<s:Boolean x:Key="/Default/CodeInspection/Browsers/Enable/@EntryValue">False</s:Boolean>
|
<s:Boolean x:Key="/Default/CodeInspection/Browsers/Enable/@EntryValue">False</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Eg_002Ecs/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ejs/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ets/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=2B54C005_002D15E8_002D40FD_002DA88A_002DA5EB9B7A2853_002Fd_003AMigrations/@EntryIndexedValue">ExplicitlyExcluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/GeneratedCode/GeneratedCodeRegions/=_002A_002Eappxmanifest/@EntryIndexedValue">*.appxmanifest</s:String>
|
<s:String x:Key="/Default/CodeInspection/GeneratedCode/GeneratedCodeRegions/=_002A_002Eappxmanifest/@EntryIndexedValue">*.appxmanifest</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/GeneratedCode/GeneratedCodeRegions/=_002A_002Ed_002Ets/@EntryIndexedValue">*.d.ts</s:String>
|
<s:String x:Key="/Default/CodeInspection/GeneratedCode/GeneratedCodeRegions/=_002A_002Ed_002Ets/@EntryIndexedValue">*.d.ts</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/GeneratedCode/GeneratedCodeRegions/=_002A_002Edebug_002Ejs/@EntryIndexedValue">*.debug.js</s:String>
|
<s:String x:Key="/Default/CodeInspection/GeneratedCode/GeneratedCodeRegions/=_002A_002Edebug_002Ejs/@EntryIndexedValue">*.debug.js</s:String>
|
||||||
|
|
@ -28,6 +32,8 @@
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeMethodOrOperatorBody/@EntryIndexedValue">SUGGESTION</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeMethodOrOperatorBody/@EntryIndexedValue">SUGGESTION</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeModifiersOrder/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeModifiersOrder/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeNamespaceBody/@EntryIndexedValue">ERROR</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeNamespaceBody/@EntryIndexedValue">ERROR</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeObjectCreationWhenTypeEvident/@EntryIndexedValue">ERROR</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeObjectCreationWhenTypeNotEvident/@EntryIndexedValue">ERROR</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeRedundantParentheses/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeRedundantParentheses/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeThisQualifier/@EntryIndexedValue">ERROR</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeThisQualifier/@EntryIndexedValue">ERROR</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeTypeMemberModifiers/@EntryIndexedValue">ERROR</s:String>
|
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeTypeMemberModifiers/@EntryIndexedValue">ERROR</s:String>
|
||||||
|
|
@ -123,9 +129,11 @@
|
||||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_IFELSE_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_IFELSE_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_USING_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_USING_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_WHILE_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/FORCE_WHILE_BRACES_STYLE/@EntryValue">ALWAYS_ADD</s:String>
|
||||||
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_BRACES_INSIDE_STATEMENT_CONDITIONS/@EntryValue">False</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_NESTED_FIXED_STMT/@EntryValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_NESTED_FIXED_STMT/@EntryValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_NESTED_USINGS_STMT/@EntryValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_NESTED_USINGS_STMT/@EntryValue">True</s:Boolean>
|
||||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_PREPROCESSOR_REGION/@EntryValue">NO_INDENT</s:String>
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_PREPROCESSOR_REGION/@EntryValue">NO_INDENT</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_RAW_LITERAL_STRING/@EntryValue">INDENT</s:String>
|
||||||
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_CODE/@EntryValue">1</s:Int64>
|
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_CODE/@EntryValue">1</s:Int64>
|
||||||
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
|
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
|
||||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_EXISTING_DECLARATION_PARENS_ARRANGEMENT/@EntryValue">False</s:Boolean>
|
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_EXISTING_DECLARATION_PARENS_ARRANGEMENT/@EntryValue">False</s:Boolean>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue