Commit baccf391 authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Fix issue with blind/batch uploaded file descriptions

When no file description was provided (e.g. blind/batch file uploads), I noticed that the short file description (summary) could be set to "(null)". This problem was introduced in commit bc7030d3 with the sbbsfile.des creation and post-processing support.

I also noticed that the extended description processing in sbbs_t::uploadfile() was not entirely consistent with other methods of adding/uploading files. Let prep_file_desc() do its just of processing the extended description into a suitable short description/summary (including truncation).
parent 067556d7
Pipeline #2764 failed with stage
in 9 minutes and 40 seconds
......@@ -68,7 +68,8 @@ bool sbbs_t::uploadfile(file_t* f)
}
SAFEPRINTF(str,"%ssbbsfile.des",cfg.node_dir);
if((stream=fopen(str,"w"))!=NULL) {
fprintf(stream, "%s", f->desc);
if(f->desc != NULL)
fprintf(stream, "%s", f->desc);
fclose(stream);
}
// Note: str (%s) is path/to/sbbsfile.des (used to be the description itself)
......@@ -98,7 +99,8 @@ bool sbbs_t::uploadfile(file_t* f)
if((stream=fopen(str,"r"))!=NULL) {
if(fgets(str, sizeof(str), stream)) {
truncsp(str);
smb_new_hfield_str(f, SMB_FILEDESC, str);
if(*str)
smb_new_hfield_str(f, SMB_FILEDESC, str);
}
fclose(stream);
}
......@@ -152,16 +154,10 @@ bool sbbs_t::uploadfile(file_t* f)
file_sauce_hfields(f, &sauce);
if(f->desc == NULL || f->desc[0] == 0) {
char desc[LEN_FDESC + 1];
char desc[LEN_EXTDESC + 1];
SAFECOPY(desc, (char*)ext);
strip_exascii(desc, desc);
prep_file_desc(desc, desc);
for(i=0;desc[i];i++)
if(IS_ALPHANUMERIC(desc[i]))
break;
if(desc[i] == '\0')
i = 0;
smb_new_hfield_str(f, SMB_FILEDESC, desc + i);
smb_new_hfield_str(f, SMB_FILEDESC, desc);
}
remove(str);
} else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment