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

Remove defunct files from batch download queue during logon

If a user doesn't have access to download a file that's in their batch queue, remove it without saying anything to the user (but log a notice-level message about it) during logon. Files that no longer exist in the filebase are treated the same way.
parent 345bd83b
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
...@@ -228,14 +228,19 @@ bool sbbs_t::logon() ...@@ -228,14 +228,19 @@ bool sbbs_t::logon()
iniFreeStringList(filenames); iniFreeStringList(filenames);
} }
/* Inform the user of what's in their batch download queue */ /* Remove defunct files from user's batch download queue and inform them of what's remaining */
{ {
str_list_t ini = batch_list_read(&cfg, useron.number, XFER_BATCH_DOWNLOAD); str_list_t ini = batch_list_read(&cfg, useron.number, XFER_BATCH_DOWNLOAD);
str_list_t filenames = iniGetSectionList(ini, NULL); str_list_t filenames = iniGetSectionList(ini, NULL);
for(size_t i = 0; filenames[i] != NULL; i++) { for(size_t i = 0; filenames[i] != NULL; i++) {
const char* filename = filenames[i]; const char* filename = filenames[i];
file_t f = {{}}; file_t f = {{}};
if(batch_file_load(&cfg, ini, filename, &f)) { if(!batch_file_load(&cfg, ini, filename, &f)
|| !can_user_download(&cfg, f.dir, &useron, &client, /* reason: */NULL)) {
lprintf(LOG_NOTICE, "Removing defunct file from user's batch download queue: %s", filename);
batch_file_remove(&cfg, useron.number, XFER_BATCH_DOWNLOAD, filename);
}
else {
char tmp2[256]; char tmp2[256];
getfilesize(&cfg, &f); getfilesize(&cfg, &f);
bprintf(text[FileAddedToBatDlQueue] bprintf(text[FileAddedToBatDlQueue]
...@@ -243,9 +248,8 @@ bool sbbs_t::logon() ...@@ -243,9 +248,8 @@ bool sbbs_t::logon()
,byte_estimate_to_str(f.cost, tmp, sizeof(tmp), 1, 1) ,byte_estimate_to_str(f.cost, tmp, sizeof(tmp), 1, 1)
,byte_estimate_to_str(f.size, tmp2, sizeof(tmp2), 1, 1) ,byte_estimate_to_str(f.size, tmp2, sizeof(tmp2), 1, 1)
,sectostr((uint)(f.size / (uint64_t)cur_cps),str)); ,sectostr((uint)(f.size / (uint64_t)cur_cps),str));
}
smb_freefilemem(&f); smb_freefilemem(&f);
} else
batch_file_remove(&cfg, useron.number, XFER_BATCH_DOWNLOAD, filename);
} }
iniFreeStringList(ini); iniFreeStringList(ini);
iniFreeStringList(filenames); iniFreeStringList(filenames);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment