Reimplement deletes and marking files as broken
This commit is contained in:
@@ -3,20 +3,20 @@ package torrent
|
||||
import cmap "github.com/orcaman/concurrent-map/v2"
|
||||
|
||||
func (t *TorrentManager) CheckDeletedStatus(torrent *Torrent) bool {
|
||||
var unselectedIDs []int
|
||||
var deletedIDs []int
|
||||
torrent.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
if file.Link == "unselect" {
|
||||
unselectedIDs = append(unselectedIDs, file.ID)
|
||||
if file.IsDeleted {
|
||||
deletedIDs = append(deletedIDs, file.ID)
|
||||
}
|
||||
})
|
||||
if len(unselectedIDs) == torrent.SelectedFiles.Count() && len(unselectedIDs) > 0 {
|
||||
if len(deletedIDs) == torrent.SelectedFiles.Count() && len(deletedIDs) > 0 {
|
||||
return true
|
||||
} else if len(unselectedIDs) > 0 {
|
||||
} else if len(deletedIDs) > 0 {
|
||||
t.saveTorrentChangesToDisk(torrent, func(info *Torrent) {
|
||||
info.SelectedFiles.IterCb(func(_ string, file *File) {
|
||||
for _, unselectedID := range unselectedIDs {
|
||||
if file.ID == unselectedID {
|
||||
file.Link = "unselect"
|
||||
for _, deletedID := range deletedIDs {
|
||||
if file.ID == deletedID {
|
||||
file.IsDeleted = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user