Adjust file reads and writes
This commit is contained in:
@@ -2,6 +2,7 @@ package torrent
|
||||
|
||||
import cmap "github.com/orcaman/concurrent-map/v2"
|
||||
|
||||
// CheckDeletedStatus checks if all files in a torrent are marked as deleted, if so, it returns true
|
||||
func (t *TorrentManager) CheckDeletedStatus(torrent *Torrent) bool {
|
||||
var deletedIDs []int
|
||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
@@ -19,8 +20,10 @@ func (t *TorrentManager) CheckDeletedStatus(torrent *Torrent) bool {
|
||||
|
||||
func (t *TorrentManager) Delete(accessKey string, deleteInRD bool) {
|
||||
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
|
||||
if deleteInRD {
|
||||
if torrent, ok := allTorrents.Get(accessKey); ok {
|
||||
var hash string
|
||||
if torrent, ok := allTorrents.Get(accessKey); ok {
|
||||
hash = torrent.Hash
|
||||
if deleteInRD {
|
||||
for torrentID := range torrent.Components {
|
||||
t.log.Debugf("Deleting torrent %s (id=%s) in RD", accessKey, torrentID)
|
||||
t.api.DeleteTorrent(torrentID)
|
||||
@@ -33,4 +36,7 @@ func (t *TorrentManager) Delete(accessKey string, deleteInRD bool) {
|
||||
torrents.Remove(accessKey)
|
||||
})
|
||||
allTorrents.Remove(accessKey)
|
||||
if hash != "" {
|
||||
t.deleteTorrentFile(hash)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user