Fixed deletion bug and extraction bug
This commit is contained in:
parent
7d9d64c97b
commit
22494a1cad
2 changed files with 45 additions and 23 deletions
|
|
@ -46,38 +46,42 @@ namespace RdtClient.Data.Data
|
||||||
|
|
||||||
public async Task<Torrent> GetById(Guid id)
|
public async Task<Torrent> GetById(Guid id)
|
||||||
{
|
{
|
||||||
var results = await _dataContext.Torrents
|
var dbTorrent = await _dataContext.Torrents
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Include(m => m.Downloads)
|
.Include(m => m.Downloads)
|
||||||
.FirstOrDefaultAsync(m => m.TorrentId == id);
|
.FirstOrDefaultAsync(m => m.TorrentId == id);
|
||||||
|
|
||||||
if (results != null)
|
if (dbTorrent == null)
|
||||||
{
|
{
|
||||||
foreach (var file in results.Downloads)
|
return null;
|
||||||
{
|
|
||||||
file.Torrent = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
foreach (var file in dbTorrent.Downloads)
|
||||||
|
{
|
||||||
|
file.Torrent = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dbTorrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Torrent> GetByHash(String hash)
|
public async Task<Torrent> GetByHash(String hash)
|
||||||
{
|
{
|
||||||
var results = await _dataContext.Torrents
|
var dbTorrent = await _dataContext.Torrents
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Include(m => m.Downloads)
|
.Include(m => m.Downloads)
|
||||||
.FirstOrDefaultAsync(m => m.Hash.ToLower() == hash.ToLower());
|
.FirstOrDefaultAsync(m => m.Hash.ToLower() == hash.ToLower());
|
||||||
|
|
||||||
if (results != null)
|
if (dbTorrent == null)
|
||||||
{
|
{
|
||||||
foreach (var file in results.Downloads)
|
return null;
|
||||||
{
|
|
||||||
file.Torrent = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
foreach (var file in dbTorrent.Downloads)
|
||||||
|
{
|
||||||
|
file.Torrent = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dbTorrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Torrent> Add(String realDebridId, String hash, Boolean autoDownload, Boolean autoDelete)
|
public async Task<Torrent> Add(String realDebridId, String hash, Boolean autoDownload, Boolean autoDelete)
|
||||||
|
|
@ -103,6 +107,11 @@ namespace RdtClient.Data.Data
|
||||||
{
|
{
|
||||||
var dbTorrent = await _dataContext.Torrents.FirstOrDefaultAsync(m => m.TorrentId == torrent.TorrentId);
|
var dbTorrent = await _dataContext.Torrents.FirstOrDefaultAsync(m => m.TorrentId == torrent.TorrentId);
|
||||||
|
|
||||||
|
if (dbTorrent == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dbTorrent.RdName = torrent.RdName;
|
dbTorrent.RdName = torrent.RdName;
|
||||||
dbTorrent.RdSize = torrent.RdSize;
|
dbTorrent.RdSize = torrent.RdSize;
|
||||||
dbTorrent.RdHost = torrent.RdHost;
|
dbTorrent.RdHost = torrent.RdHost;
|
||||||
|
|
@ -126,6 +135,11 @@ namespace RdtClient.Data.Data
|
||||||
{
|
{
|
||||||
var dbTorrent = await _dataContext.Torrents.FirstOrDefaultAsync(m => m.TorrentId == torrentId);
|
var dbTorrent = await _dataContext.Torrents.FirstOrDefaultAsync(m => m.TorrentId == torrentId);
|
||||||
|
|
||||||
|
if (dbTorrent == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dbTorrent.Status = status;
|
dbTorrent.Status = status;
|
||||||
|
|
||||||
await _dataContext.SaveChangesAsync();
|
await _dataContext.SaveChangesAsync();
|
||||||
|
|
@ -135,6 +149,11 @@ namespace RdtClient.Data.Data
|
||||||
{
|
{
|
||||||
var dbTorrent = await _dataContext.Torrents.FirstOrDefaultAsync(m => m.TorrentId == torrentId);
|
var dbTorrent = await _dataContext.Torrents.FirstOrDefaultAsync(m => m.TorrentId == torrentId);
|
||||||
|
|
||||||
|
if (dbTorrent == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dbTorrent.Category = category;
|
dbTorrent.Category = category;
|
||||||
|
|
||||||
await _dataContext.SaveChangesAsync();
|
await _dataContext.SaveChangesAsync();
|
||||||
|
|
@ -144,6 +163,11 @@ namespace RdtClient.Data.Data
|
||||||
{
|
{
|
||||||
var dbTorrent = await _dataContext.Torrents.FirstOrDefaultAsync(m => m.TorrentId == id);
|
var dbTorrent = await _dataContext.Torrents.FirstOrDefaultAsync(m => m.TorrentId == id);
|
||||||
|
|
||||||
|
if (dbTorrent == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_dataContext.Torrents.Remove(dbTorrent);
|
_dataContext.Torrents.Remove(dbTorrent);
|
||||||
|
|
||||||
await _dataContext.SaveChangesAsync();
|
await _dataContext.SaveChangesAsync();
|
||||||
|
|
|
||||||
|
|
@ -140,15 +140,13 @@ namespace RdtClient.Service.Services
|
||||||
|
|
||||||
var extractPath = destinationFolderPath;
|
var extractPath = destinationFolderPath;
|
||||||
|
|
||||||
if (!entries.Any(m => m.Key.StartsWith(torrentName)))
|
if (!entries.Any(m => m.Key.StartsWith(torrentName + @"\")) && !entries.Any(m => m.Key.StartsWith(torrentName + @"/")))
|
||||||
{
|
{
|
||||||
extractPath = Path.Combine(destinationFolderPath, torrentName);
|
extractPath = Path.Combine(destinationFolderPath, torrentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var entry in entries)
|
foreach (var entry in entries)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
_rarCurrentEntry = entry;
|
_rarCurrentEntry = entry;
|
||||||
|
|
||||||
entry.WriteToDirectory(extractPath,
|
entry.WriteToDirectory(extractPath,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue