@seedvault/server 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -151,6 +151,8 @@ function deleteContributor(username) {
151
151
  d.prepare("DELETE FROM activity WHERE contributor = ?").run(username);
152
152
  d.prepare("DELETE FROM items WHERE contributor = ?").run(username);
153
153
  d.prepare("DELETE FROM api_keys WHERE contributor = ?").run(username);
154
+ d.prepare("UPDATE invites SET used_by = NULL WHERE used_by = ?").run(username);
155
+ d.prepare("DELETE FROM invites WHERE created_by = ?").run(username);
154
156
  d.prepare("DELETE FROM contributors WHERE username = ?").run(username);
155
157
  return true;
156
158
  }
@@ -220,7 +222,12 @@ function upsertItem(contributor, path, content, originCtime, originMtime) {
220
222
  VALUES (?, ?, ?, ?, ?)
221
223
  ON CONFLICT (contributor, path) DO UPDATE SET
222
224
  content = excluded.content,
223
- modified_at = excluded.modified_at`).run(contributor, path, content, createdAt, modifiedAt);
225
+ modified_at = excluded.modified_at,
226
+ created_at = CASE
227
+ WHEN excluded.created_at < items.created_at
228
+ THEN excluded.created_at
229
+ ELSE items.created_at
230
+ END`).run(contributor, path, content, createdAt, modifiedAt);
224
231
  return getItem(contributor, path);
225
232
  }
226
233
  function getItem(contributor, path) {
@@ -2176,9 +2183,8 @@ function createApp() {
2176
2183
  return c.json({ error: pathError }, 400);
2177
2184
  }
2178
2185
  const content = await c.req.text();
2179
- const now = new Date().toISOString();
2180
- const originCtime = c.req.header("X-Origin-Ctime") || now;
2181
- const originMtime = c.req.header("X-Origin-Mtime") || now;
2186
+ const originCtime = c.req.header("X-Origin-Ctime") || undefined;
2187
+ const originMtime = c.req.header("X-Origin-Mtime") || undefined;
2182
2188
  const existing = getItem(parsed.username, parsed.filePath);
2183
2189
  try {
2184
2190
  const item = upsertItem(parsed.username, parsed.filePath, content, originCtime, originMtime);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seedvault/server",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "seedvault-server": "bin/seedvault-server.mjs"