Skip to content
Snippets Groups Projects
Commit 86e39e82 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Allow files to be removed from batch queues by number

This fixes issue #328.

The user actually *can* remove files from the batch queues in v3.19b, but you have to type the filenames which is not obvious from the prompt which implies you need to type the file index position (e.g. '1' for the first file in the queue). In all Synchronet versions prior, you could only remove by number (and not by name).

The fix is to allow either the number or the name of the file to be entered at the RemoveWhich prompt and the file is removed from the queue successfully.

Thanks Ragnarok!
parent 85fe6b47
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #2634 passed
......@@ -148,12 +148,14 @@ void sbbs_t::batchmenu()
if((n = batup_total()) > 0) {
bprintf(text[RemoveWhichFromUlQueue], n);
if(getstr(str, MAX_FILENAME_LEN, K_NONE) > 0)
batch_file_remove(&cfg, useron.number, XFER_BATCH_UPLOAD, str);
if(!batch_file_remove(&cfg, useron.number, XFER_BATCH_UPLOAD, str) && (n = atoi(str)) > 0)
batch_file_remove_n(&cfg, useron.number, XFER_BATCH_UPLOAD, n - 1);
}
if((n = batdn_total()) > 0) {
bprintf(text[RemoveWhichFromDlQueue], n);
if(getstr(str, MAX_FILENAME_LEN, K_NONE) > 0)
batch_file_remove(&cfg, useron.number, XFER_BATCH_DOWNLOAD, str);
if(!batch_file_remove(&cfg, useron.number, XFER_BATCH_DOWNLOAD, str) && (n = atoi(str)) > 0)
batch_file_remove_n(&cfg, useron.number, XFER_BATCH_DOWNLOAD, n - 1);
}
break;
case 'U':
......
......@@ -411,6 +411,25 @@ bool batch_file_remove(scfg_t* cfg, uint usernumber, enum XFER_TYPE type, const
return result;
}
// 'n' is zero-based index of file to remove
bool batch_file_remove_n(scfg_t* cfg, uint usernumber, enum XFER_TYPE type, uint n)
{
FILE* fp = batch_list_open(cfg, usernumber, type, /* create: */false);
if(fp == NULL)
return false;
str_list_t ini = iniReadFile(fp);
str_list_t files = iniGetSectionList(ini, NULL);
bool result = false;
if(n < strListCount(files))
result = iniRemoveSection(&ini, files[n]);
iniWriteFile(fp, ini);
iniCloseFile(fp);
iniFreeStringList(ini);
iniFreeStringList(files);
return result;
}
bool batch_file_exists(scfg_t* cfg, uint usernumber, enum XFER_TYPE type, const char* filename)
{
FILE* fp = batch_list_open(cfg, usernumber, type, /* create: */false);
......
......@@ -87,6 +87,7 @@ DLLEXPORT bool batch_list_clear(scfg_t*, uint usernumber, enum XFER_TYPE);
DLLEXPORT bool batch_file_add(scfg_t*, uint usernumber, enum XFER_TYPE, file_t*);
DLLEXPORT bool batch_file_exists(scfg_t*, uint usernumber, enum XFER_TYPE, const char* filename);
DLLEXPORT bool batch_file_remove(scfg_t*, uint usernumber, enum XFER_TYPE, const char* filename);
DLLEXPORT bool batch_file_remove_n(scfg_t*, uint usernumber, enum XFER_TYPE, uint n);
DLLEXPORT size_t batch_file_count(scfg_t*, uint usernumber, enum XFER_TYPE);
DLLEXPORT bool batch_file_get(scfg_t*, str_list_t, const char* filename, file_t*);
DLLEXPORT int batch_file_dir(scfg_t*, str_list_t, const char* filename);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment