Reimplement deletes and marking files as broken
This commit is contained in:
@@ -29,14 +29,14 @@ func HandleDeleteFile(directory, torrentName, fileName string, torMgr *torrent.T
|
||||
return fmt.Errorf("cannot find torrent %s", torrentName)
|
||||
}
|
||||
file, ok := torrent.SelectedFiles.Get(fileName)
|
||||
if !ok {
|
||||
if !ok || file.IsDeleted {
|
||||
return fmt.Errorf("cannot find file %s", fileName)
|
||||
}
|
||||
dirCfg := torMgr.Config.(*config.ZurgConfigV1).GetDirectoryConfig(directory)
|
||||
if dirCfg.OnlyShowTheBiggestFile {
|
||||
torMgr.Delete(torrentName, true)
|
||||
} else {
|
||||
file.Link = "unselect"
|
||||
file.IsDeleted = true
|
||||
if torMgr.CheckDeletedStatus(torrent) {
|
||||
torMgr.Delete(torrentName, true)
|
||||
}
|
||||
|
||||
@@ -74,8 +74,8 @@ func ServeFilesListForInfuse(directory, torrentName string, torMgr *torrent.Torr
|
||||
filenames := tor.SelectedFiles.Keys()
|
||||
sort.Strings(filenames)
|
||||
for _, filename := range filenames {
|
||||
file, ok := tor.SelectedFiles.Get(filename)
|
||||
if !ok || !strings.HasPrefix(file.Link, "http") {
|
||||
file, _ := tor.SelectedFiles.Get(filename)
|
||||
if file.IsDeleted {
|
||||
continue
|
||||
}
|
||||
if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize {
|
||||
@@ -104,7 +104,7 @@ func ServeDownloadsListForInfuse(torMgr *torrent.TorrentManager) ([]byte, error)
|
||||
sort.Strings(filenames)
|
||||
for _, filename := range filenames {
|
||||
download, ok := torMgr.DownloadMap.Get(filename)
|
||||
if !ok || !strings.HasPrefix(download.Link, "http") {
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
buf.WriteString(dav.File(download.Filename, download.Filesize, download.Generated))
|
||||
|
||||
@@ -78,8 +78,8 @@ func ServeFilesList(directory, torrentName string, torMgr *torrent.TorrentManage
|
||||
filenames := tor.SelectedFiles.Keys()
|
||||
sort.Strings(filenames)
|
||||
for _, filename := range filenames {
|
||||
file, ok := tor.SelectedFiles.Get(filename)
|
||||
if !ok || !strings.HasPrefix(file.Link, "http") {
|
||||
file, _ := tor.SelectedFiles.Get(filename)
|
||||
if file.IsDeleted {
|
||||
continue
|
||||
}
|
||||
if dirCfg.OnlyShowTheBiggestFile && file.Bytes < biggestFileSize {
|
||||
@@ -107,7 +107,7 @@ func HandleSingleFile(directory, torrentName, fileName string, torMgr *torrent.T
|
||||
return nil, fmt.Errorf("cannot find torrent %s", torrentName)
|
||||
}
|
||||
file, ok := tor.SelectedFiles.Get(fileName)
|
||||
if !ok || !strings.HasPrefix(file.Link, "http") {
|
||||
if !ok || file.IsDeleted {
|
||||
return nil, fmt.Errorf("cannot find file %s", fileName)
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ func ServeDownloadsList(torMgr *torrent.TorrentManager) ([]byte, error) {
|
||||
sort.Strings(filenames)
|
||||
for _, filename := range filenames {
|
||||
download, ok := torMgr.DownloadMap.Get(filename)
|
||||
if !ok || !strings.HasPrefix(download.Link, "http") {
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
buf.WriteString(dav.File(download.Filename, download.Filesize, download.Generated))
|
||||
|
||||
@@ -31,11 +31,12 @@ func HandleRenameFile(directory, torrentName, fileName, newName string, torMgr *
|
||||
return fmt.Errorf("cannot find torrent %s", torrentName)
|
||||
}
|
||||
file, ok := torrent.SelectedFiles.Get(fileName)
|
||||
if !ok {
|
||||
if !ok || file.IsDeleted {
|
||||
return fmt.Errorf("cannot find file %s", fileName)
|
||||
}
|
||||
torrent.SelectedFiles.Remove(torrentName)
|
||||
oldName := torMgr.GetPath(file)
|
||||
file.Rename = newName
|
||||
torrent.SelectedFiles.Set(newName, file)
|
||||
file.Path = newName
|
||||
torrent.SelectedFiles.Remove(oldName)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user