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

Fix issues with file header fields getting repeated (cloned)

e.g. when using the JS FileBase.update() method
parent 567c86d7
No related branches found
No related tags found
No related merge requests found
......@@ -615,13 +615,13 @@ int file_sauce_hfields(file_t* f, struct sauce_charinfo* info)
if(info == NULL)
return -1;
if(*info->author && (i = smb_hfield_str(f, SMB_AUTHOR, info->author)) != SMB_SUCCESS)
if(*info->author && (i = smb_new_hfield_str(f, SMB_AUTHOR, info->author)) != SMB_SUCCESS)
return i;
if(*info->group && (i = smb_hfield_str(f, SMB_AUTHOR_ORG, info->group)) != SMB_SUCCESS)
if(*info->group && (i = smb_new_hfield_str(f, SMB_AUTHOR_ORG, info->group)) != SMB_SUCCESS)
return i;
if(f->desc == NULL && *info->title && (i = smb_hfield_str(f, SMB_FILEDESC, info->title)) != SMB_SUCCESS)
if(f->desc == NULL && *info->title && (i = smb_new_hfield_str(f, SMB_FILEDESC, info->title)) != SMB_SUCCESS)
return i;
return SMB_SUCCESS;
......@@ -636,7 +636,8 @@ bool addfile(scfg_t* cfg, uint dirnum, file_t* f, const char* extdesc, client_t*
return false;
getfilepath(cfg, f, fpath);
file_client_hfields(f, client);
if(f->from_ip == NULL)
file_client_hfields(f, client);
str_list_t list = list_archive_contents(fpath, /* pattern: */NULL
,(cfg->dir[dirnum]->misc & DIR_NOHASH) == 0, /* error: */NULL, /* size: */0);
int result = smb_addfile_withlist(&smb, f, SMB_SELFPACK, extdesc, list, fpath);
......
......@@ -494,7 +494,7 @@ parse_file_properties(JSContext *cx, JSObject* obj, file_t* file, char** extdesc
JS_ReportError(cx, "Invalid '%s' string in file object", prop_name);
return SMB_FAILURE;
}
if(smb_hfield_str(file, SENDERIPADDR, cp) != SMB_SUCCESS) {
if(smb_new_hfield_str(file, SENDERIPADDR, cp) != SMB_SUCCESS) {
free(cp);
JS_ReportError(cx, "Error %d adding '%s' property to file object", result, prop_name);
return result;
......@@ -509,7 +509,7 @@ parse_file_properties(JSContext *cx, JSObject* obj, file_t* file, char** extdesc
JS_ReportError(cx, "Invalid '%s' string in file object", prop_name);
return SMB_FAILURE;
}
if(smb_hfield_str(file, SENDERHOSTNAME, cp) != SMB_SUCCESS) {
if(smb_new_hfield_str(file, SENDERHOSTNAME, cp) != SMB_SUCCESS) {
free(cp);
JS_ReportError(cx, "Error %d adding '%s' property to file object", result, prop_name);
return result;
......@@ -524,7 +524,7 @@ parse_file_properties(JSContext *cx, JSObject* obj, file_t* file, char** extdesc
JS_ReportError(cx, "Invalid '%s' string in file object", prop_name);
return SMB_FAILURE;
}
if(smb_hfield_str(file, SENDERPROTOCOL, cp) != SMB_SUCCESS) {
if(smb_new_hfield_str(file, SENDERPROTOCOL, cp) != SMB_SUCCESS) {
free(cp);
JS_ReportError(cx, "Error %d adding '%s' property to file object", result, prop_name);
return result;
......@@ -539,7 +539,7 @@ parse_file_properties(JSContext *cx, JSObject* obj, file_t* file, char** extdesc
JS_ReportError(cx, "Invalid '%s' string in file object", prop_name);
return SMB_FAILURE;
}
if(smb_hfield_str(file, SENDERPORT, cp) != SMB_SUCCESS) {
if(smb_new_hfield_str(file, SENDERPORT, cp) != SMB_SUCCESS) {
free(cp);
JS_ReportError(cx, "Error %d adding '%s' property to file object", result, prop_name);
return result;
......@@ -554,7 +554,7 @@ parse_file_properties(JSContext *cx, JSObject* obj, file_t* file, char** extdesc
JS_ReportError(cx, "Invalid '%s' string in file object", prop_name);
return SMB_FAILURE;
}
if(smb_hfield_str(file, SMB_AUTHOR, cp) != SMB_SUCCESS) {
if(smb_new_hfield_str(file, SMB_AUTHOR, cp) != SMB_SUCCESS) {
free(cp);
JS_ReportError(cx, "Error %d adding '%s' property to file object", result, prop_name);
return result;
......@@ -569,7 +569,7 @@ parse_file_properties(JSContext *cx, JSObject* obj, file_t* file, char** extdesc
JS_ReportError(cx, "Invalid '%s' string in file object", prop_name);
return SMB_FAILURE;
}
if(smb_hfield_str(file, SMB_AUTHOR_ORG, cp) != SMB_SUCCESS) {
if(smb_new_hfield_str(file, SMB_AUTHOR_ORG, cp) != SMB_SUCCESS) {
free(cp);
JS_ReportError(cx, "Error %d adding '%s' property to file object", result, prop_name);
return result;
......@@ -1234,7 +1234,8 @@ js_add_file(JSContext *cx, uintN argc, jsval *arglist)
}
char fpath[MAX_PATH + 1];
getfilepath(scfg, &file, fpath);
file_client_hfields(&file, client);
if(file.from_ip == NULL)
file_client_hfields(&file, client);
str_list_t list = list_archive_contents(fpath, /* pattern: */NULL
,(scfg->dir[file.dir]->misc & DIR_NOHASH) == 0, /* error: */NULL, /* size: */0);
p->smb_result = smb_addfile_withlist(&p->smb, &file, SMB_SELFPACK, extdesc, list, fpath);
......
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