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

Check free disk space when batch-uploading to the blind upload directory

This fixes issue #516
parent 521a84b3
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #3774 passed
......@@ -240,9 +240,9 @@
"\1r\1hFilenames, specs, or flags [None]: \1m\1h\1~" 197 BatchDlFlags
"\r\n\7\1r\1h\1iBatch download queue is full.\1n\r\n" 198 BatchDlQueueIsFull
"\1_\1?\1y\1hFilespec [\1wAll Files\1y]: \1n" 199 FileSpecStarDotStar
"\r\n\r\n\1r\1h\1iNot enough free disk space.\1n\r\n"\ 200 LowDiskSpace
"\1?\1r\1h\1iNot enough free disk space.\1n\r\n"\ 200 LowDiskSpace
"\r\n\1hThe sysop has been notified.\1n\r\n"
"\r\n%s kilobytes free\r\n\r\n" 201 DiskNBytesFree
"\r\n%s bytes free\r\n\r\n" 201 DiskNBytesFree
"\1_\1y\1hFilename: \1n" 202 Filename
"\1/\1r\1hBad filename: '%s'\r\n" 203 BadFilename
"Upload '%s' to Sysop directory" 204 UploadToSysopDirQ
......@@ -705,7 +705,7 @@
"upcoming event on \1w%s\r\n\r\n"
"\1n\r\nTimed Event - Node: %d Time: %02d:%02d "\ 568 EventInfo
"Last Ran: %s\r\n"
"\1_\1r\1h\1i\r\n\r\nConnection will be dropped in %d "\ 569 UploadBeforeEvent
"\1_\1r\1h\1i\1?Connection will be dropped in %d "\ 569 UploadBeforeEvent
"minutes due to upcoming event.\1n"
"\1_\1y\1h\r\nQWK: \1n" 570 QWKPrompt
"\r\nCtrl-A codes: ~Expand to ANSI, ~Leave in, or "\ 571 QWKCtrlACodes
......@@ -1045,4 +1045,4 @@
"%.0s\1n\1h\1m%s \1n\1msent you EchoMail on "\ 860 FidoEchoMailReceived
"\1h%s \1n\1m%s\1n\r\n"
"\1_\1w\1hCalculating file's hash values @ELLIPSIS@\1n" 861 HashingFile
"\1[\1>" 862 HashedFile
\ No newline at end of file
"\1[\1>" 862 HashedFile
......@@ -182,6 +182,8 @@ void sbbs_t::batchmenu()
bputs(text[UploadQueueIsEmpty]);
break;
}
if(cfg.upload_dir != INVALID_DIR && !okay_to_upload(cfg.upload_dir))
break;
xfer_prot_menu(XFER_BATCH_UPLOAD);
if(!create_batchup_lst())
break;
......
......@@ -1040,6 +1040,7 @@ public:
/* upload.cpp */
bool uploadfile(file_t* f);
bool okay_to_upload(uint dirnum);
bool upload(uint dirnum);
char upload_lastdesc[LEN_FDESC+1];
bool bulkupload(uint dirnum);
......
......@@ -199,6 +199,32 @@ bool sbbs_t::uploadfile(file_t* f)
return true;
}
bool sbbs_t::okay_to_upload(uint dirnum)
{
char str[MAX_PATH + 1];
char path[MAX_PATH + 1];
SAFECOPY(path, cfg.dir[dirnum]->path);
if(!isdir(path)) {
bprintf(text[DirectoryDoesNotExist], path);
lprintf(LOG_ERR,"File directory does not exist: %s", path);
return(false);
}
/* get free disk space */
ulong space = getfreediskspace(path, 1024);
byte_count_to_str(space * 1024, str, sizeof(str));
if(space < (ulong)(cfg.min_dspace / 1024)) {
bputs(text[LowDiskSpace]);
lprintf(LOG_ERR, "Diskspace is low: %s (%s bytes)", path, str);
if(!dir_op(dirnum))
return(false);
}
bprintf(text[DiskNBytesFree], str);
return true;
}
/****************************************************************************/
/* Uploads files */
/****************************************************************************/
......@@ -211,7 +237,6 @@ bool sbbs_t::upload(uint dirnum)
char tmp[512];
time_t start,end;
uint i,j,k;
ulong space;
file_t f = {{}};
str_list_t dest_user_list = NULL;
......@@ -239,23 +264,8 @@ bool sbbs_t::upload(uint dirnum)
if(sys_status&SS_EVENT && online==ON_REMOTE && !dir_op(dirnum))
bprintf(text[UploadBeforeEvent],timeleft/60);
SAFECOPY(path,cfg.dir[dirnum]->path);
if(!isdir(path)) {
bprintf(text[DirectoryDoesNotExist], path);
lprintf(LOG_ERR,"File directory does not exist: %s", path);
return(false);
}
/* get free disk space */
space=getfreediskspace(path,1024);
if(space<(ulong)(cfg.min_dspace / 1024)) {
bputs(text[LowDiskSpace]);
lprintf(LOG_ERR,"Diskspace is low: %s (%lu KB)",path,space);
if(!dir_op(dirnum))
return(false);
}
bprintf(text[DiskNBytesFree],ultoac(space,tmp));
if(!okay_to_upload(dirnum))
return false;
f.dir=curdirnum=dirnum;
bputs(text[Filename]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment