- struct odes *o = task_status_find_task(c, task);
- task_submit(c, task, fb, task->name);
- log(L_INFO, "User %s submitted task %s", c->user, task->name);
+ struct odes *tasko = task_status_find_task(c, task, 1);
+ struct odes *parto = task_status_find_part(tasko, pname, 1);
+ uns current_ver = obj_find_anum(parto, 'V', 0);
+ uns last_ver = 0;
+ uns replaced_ver = 0;
+ for (struct oattr *a = obj_find_attr(parto, 'V' + OBJ_ATTR_SON); a; a=a->same)
+ {
+ uns ver = obj_find_anum(a->son, 'V', 0);
+ byte *ext = obj_find_aval(a->son, 'X');
+ ASSERT(ver && ext);
+ last_ver = MAX(last_ver, ver);
+ if (ver == current_ver)
+ {
+ task_delete_part(c->user, tname, pname, ext, ver);
+ obj_set_attr(a->son, 'S', "replaced");
+ replaced_ver = current_ver;
+ }
+ }
+ struct odes *vero = obj_add_son(parto, 'V' + OBJ_ATTR_SON);
+ obj_set_attr_num(vero, 'V', ++last_ver);
+ obj_set_attr_num(vero, 'T', time(NULL));
+ obj_set_attr(vero, 'S', "submitted");
+ obj_set_attr(vero, 'X', ext);
+ // FIXME: hash
+ // FIXME: remove old versions from the status file?
+ task_submit_part(c->user, tname, pname, ext, last_ver, fb);
+ obj_set_attr_num(parto, 'V', last_ver);