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

Fix issues with file header fields getting repeated (cloned)

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