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

add() method will now parse added, last_downloaded, and times_downloaded

These 3 'stats' properties were read-only (never used when adding a file). To support moving files between FileBases while retaining these stats, support the parse/use of these file-meta-object property values.

Should fix issue #333 reported by Nightfox.
parent 5f2881f2
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #2658 passed
......@@ -572,7 +572,7 @@ parse_file_properties(JSContext *cx, JSObject* obj, file_t* file, char** extdesc
uint32_t cost = 0;
if(!JS_ValueToECMAUint32(cx, val, &cost)) {
free(cp);
JS_ReportError(cx, "Error converting adding '%s' property to Uint32", prop_name);
JS_ReportError(cx, "Error converting '%s' property to Uint32", prop_name);
return SMB_FAILURE;
}
if((file->cost != 0 || cost != 0) && (result = smb_new_hfield(file, SMB_COST, sizeof(cost), &cost)) != SMB_SUCCESS) {
......@@ -581,6 +581,36 @@ parse_file_properties(JSContext *cx, JSObject* obj, file_t* file, char** extdesc
return result;
}
}
prop_name = "added";
if(JS_GetProperty(cx, obj, prop_name, &val) && !JSVAL_NULL_OR_VOID(val)) {
uint32_t t = 0;
if(!JS_ValueToECMAUint32(cx, val, &t)) {
free(cp);
JS_ReportError(cx, "Error converting '%s' property to Uint32", prop_name);
return SMB_FAILURE;
}
file->hdr.when_imported.time = t;
}
prop_name = "last_downloaded";
if(JS_GetProperty(cx, obj, prop_name, &val) && !JSVAL_NULL_OR_VOID(val)) {
uint32_t t = 0;
if(!JS_ValueToECMAUint32(cx, val, &t)) {
free(cp);
JS_ReportError(cx, "Error converting '%s' property to Uint32", prop_name);
return SMB_FAILURE;
}
file->hdr.last_downloaded = t;
}
prop_name = "times_downloaded";
if(JS_GetProperty(cx, obj, prop_name, &val) && !JSVAL_NULL_OR_VOID(val)) {
uint32_t t = 0;
if(!JS_ValueToECMAUint32(cx, val, &t)) {
free(cp);
JS_ReportError(cx, "Error converting '%s' property to Uint32", prop_name);
return SMB_FAILURE;
}
file->hdr.times_downloaded = t;
}
if(JS_GetProperty(cx, obj, "anon", &val) && val == JSVAL_TRUE)
file->hdr.attr |= FILE_ANONYMOUS;
......
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