History

Remove unused attachment route path helpers

- delete route-to-path conversion helpers from `attachmentPaths` - remove unused `attachmentRoutePath` export and route prefix import

Julius Marminge committed 8 months ago

Commit a356cd01 parent 58b932f2 files · +0 −27Browse files

Unified · Split

2 files
  1. apps/server/src/attachmentPaths.ts +0 −22
  2. apps/server/src/attachmentStore.ts +0 −5
apps/server/src/attachmentPaths.ts+0−22
@@ -10,14 +10,6 @@ export function normalizeAttachmentRelativePath(rawRelativePath: string): string · 9 unmodified lines
10 return normalized.replace(/\\/g, "/");10 return normalized.replace(/\\/g, "/");
11}11}
12 12
13export function attachmentRouteToRelativePath(dataUrl: string): string | null {
14 const prefix = `${ATTACHMENTS_ROUTE_PREFIX}/`;
15 if (!dataUrl.startsWith(prefix)) {
16 return null;
17 }
18 return normalizeAttachmentRelativePath(dataUrl.slice(prefix.length));
19}
20
21export function resolveAttachmentRelativePath(input: {13export function resolveAttachmentRelativePath(input: {
22 readonly stateDir: string;14 readonly stateDir: string;
23 readonly relativePath: string;15 readonly relativePath: string;
@@ -34,17 +26,3 @@ export function resolveAttachmentRelativePath(input: { · 10 unmodified lines
34 }26 }
35 return filePath;27 return filePath;
36}28}
37
38export function resolveAttachmentRoutePath(input: {
39 readonly stateDir: string;
40 readonly dataUrl: string;
41}): string | null {
42 const relativePath = attachmentRouteToRelativePath(input.dataUrl);
43 if (!relativePath) {
44 return null;
45 }
46 return resolveAttachmentRelativePath({
47 stateDir: input.stateDir,
48 relativePath,
49 });
50}
apps/server/src/attachmentStore.ts+0−5
@@ -4,7 +4,6 @@ import { existsSync } from "node:fs"; · 3 unmodified lines
4import type { ChatAttachment } from "@t3tools/contracts";4import type { ChatAttachment } from "@t3tools/contracts";
5 5
6import {6import {
7 ATTACHMENTS_ROUTE_PREFIX,
8 normalizeAttachmentRelativePath,7 normalizeAttachmentRelativePath,
9 resolveAttachmentRelativePath,8 resolveAttachmentRelativePath,
10} from "./attachmentPaths.ts";9} from "./attachmentPaths.ts";
@@ -77,10 +76,6 @@ export function resolveAttachmentPath(input: { · 66 unmodified lines
77 });76 });
78}77}
79 78
80export function attachmentRoutePath(attachment: ChatAttachment): string {
81 return `${ATTACHMENTS_ROUTE_PREFIX}/${encodeURIComponent(attachment.id)}`;
82}
83
84export function resolveAttachmentPathById(input: {79export function resolveAttachmentPathById(input: {
85 readonly stateDir: string;80 readonly stateDir: string;
86 readonly attachmentId: string;81 readonly attachmentId: string;