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

Set destination directory in proper file_t instance in movefile()

This fixes the issue (#515) that was introduced 9 months ago
(after the v3.19b release) with commit b1449b27.

Also:
	movefile() will now log an error message if addfile() fails.
	Fix the message logged when the file is successfully moved.
parent 0664b6ad
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
......@@ -235,22 +235,24 @@ bool sbbs_t::movefile(smb_t* smb, file_t* f, int newdir)
file_t newfile = *f;
if(findfile(&cfg, newdir, f->name, NULL)) {
bprintf(text[FileAlreadyThere], f->name);
return false;
return false;
}
f->dir = newdir;
newfile.dir = newdir;
newfile.dfield = NULL; // addfile() ends up realloc'ing dfield (in smb_addmsg)
bool result = addfile(&cfg, &newfile, newfile.extdesc, newfile.metadata, /* client: */NULL);
free(newfile.dfield);
if(!result)
if(!result) {
errormsg(WHERE, "adding file", f->name, newfile.dir);
return false;
}
if(!removefile(smb, f)) // Use ::removefile() here instead?
return false;
bprintf(text[MovedFile],f->name
,cfg.lib[cfg.dir[newdir]->lib]->sname,cfg.dir[newdir]->sname);
char str[MAX_PATH+1];
SAFEPRINTF4(str, "%s moved %s to %s %s",f->name
,useron.alias
SAFEPRINTF3(str, "moved %s to %s %s"
,f->name
,cfg.lib[cfg.dir[newdir]->lib]->sname
,cfg.dir[newdir]->sname);
logline(nulstr,str);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment