shithub: todofs

Download patch

ref: a895be69922ed23ff37f898a714374d03de02187
parent: 423f4db8e2a87e2319834ea9896a3d568cb64334
author: sirjofri <[email protected]>
date: Thu Jun 20 15:35:27 EDT 2024

adds wstat with assignee support

--- a/todofs.c
+++ b/todofs.c
@@ -335,8 +335,9 @@
 	
 	freetask(t);
 	
-	if (title)
+	if (title) {
 		t->title = strdup(title);
+	}
 	t->dir = dirstat(path);
 	if (assignee) {
 		t->dir->uid = strdup(assignee);
@@ -759,6 +760,46 @@
 	respond(r, nil);
 }
 
+static void
+fswstat(Req *r)
+{
+	Task *t;
+	int save = 0;
+	
+	switch (qidtype(r->fid->qid.path)) {
+	case Qtask:
+		t = getgtask(qidnum(r->fid->qid.path), nil);
+		if (!t) {
+			respond(r, "invalid task");
+			return;
+		}
+		
+		if (r->d.uid && r->d.uid[0]) {
+			if (t->cassignee && t->dir->uid)
+				free(t->dir->uid);
+			t->dir->uid = strdup(r->d.uid);
+			t->cassignee = 1;
+			save++;
+		}
+		if (r->d.gid && r->d.gid[0]) {
+			if (t->cgroup && t->dir->gid)
+				free(t->dir->gid);
+			t->dir->gid = strdup(r->d.gid);
+			t->cgroup = 1;
+			save++;
+		}
+		
+		if (save)
+			savedata();
+		
+		break;
+	default:
+		respond(r, "invalid operation");
+		return;
+	}
+	respond(r, nil);
+}
+
 Srv fs = {
 	.attach = fsattach,
 	.open = fsopen,
@@ -767,6 +808,7 @@
 	.create = fscreate,
 	.walk1 = fswalk1,
 	.stat = fsstat,
+	.wstat = fswstat,
 };
 
 void