feat(drive): remove all owner_id from {File,Folder}Dto

This commit is contained in:
Edouard Vanbelle
2026-07-03 00:48:14 +02:00
parent 29bcf48eb7
commit 37467ed9d3
33 changed files with 116 additions and 149 deletions
+9 -24
View File
@@ -24,26 +24,17 @@ export interface FolderItem {
is_root: boolean;
modified_at: number;
name: string;
// `null` on share-recipient responses — the backend's
// `FolderDto::without_hierarchy_info` (folder_dto.rs:154) clears
// hierarchy fields (including owner_id) for non-owner callers.
// Backend serialises `Option<String>` (folder_dto.rs:53); this
// type just tells the truth about the wire.
//
// Deprecated post-D7 (frontend cutover): callers should prefer
// `created_by` / `updated_by` instead — they carry §14 provenance
// and survive the drop of `storage.folders.user_id`. The
// `owner_id` field will be removed from the wire once every
// callsite has moved.
owner_id: string | null;
// §14 provenance — who originally created the folder. `null` when
// the creating user has since been deleted (backend FK is
// `ON DELETE SET NULL`). Preferred over `owner_id` on the Files
// browser owner column and the Favorites / Shared surfaces.
// `ON DELETE SET NULL`), or when the folder is returned to a
// share recipient that lost provenance via
// `FolderDto::without_hierarchy_info`. The canonical "owner"
// signal on the Files browser / Favorites / Shared surfaces
// (replaced the retired `owner_id` field in D7).
created_by: string | null;
// §14 provenance — who last touched the folder (rename / move /
// metadata change). Preferred over `owner_id` on the Recent
// surface, where "who touched this recently" is the intent.
// metadata change). The canonical "who touched this recently"
// signal on the Recent surface.
updated_by: string | null;
parent_id: string | null;
path: string;
@@ -59,13 +50,8 @@ export interface FileItem {
mime_type: string;
modified_at: number;
name: string;
// `null` on share-recipient responses (same as FolderItem above).
// Backend serialises `Option<String>` at file_dto.rs:59.
//
// Deprecated post-D7 (frontend cutover): prefer `created_by` /
// `updated_by` as documented on `FolderItem`.
owner_id: string | null;
// §14 provenance — see FolderItem for semantics.
// §14 provenance — see FolderItem for semantics. Replaced the
// retired `owner_id` field in D7.
created_by: string | null;
updated_by: string | null;
folder_id: string;
@@ -124,7 +110,6 @@ export interface FavoriteItem {
icon_special_class: string;
category: string;
size_formatted: string;
owner_id: string | null;
}
export interface RecentItem {
@@ -28,7 +28,6 @@ function file(over: Record<string, unknown> = {}) {
mime_type: 'image/png',
category: 'Image',
folder_id: '',
owner_id: '',
created_by: null,
updated_by: null,
path: '',
@@ -57,7 +57,6 @@ function folder(id: string, name: string) {
is_root: false,
modified_at: 0,
name,
owner_id: 'me',
created_by: 'me',
updated_by: 'me',
parent_id: 'home',
@@ -20,7 +20,6 @@ function item(id: string) {
mime_type: 'image/jpeg',
category: 'Image',
folder_id: '',
owner_id: '',
created_by: null,
updated_by: null,
path: '',
-1
View File
@@ -30,7 +30,6 @@ export function minimalPhotoItem(id: string): FileItem {
mime_type: 'image/jpeg',
modified_at: 0,
name: '',
owner_id: '',
created_by: null,
updated_by: null,
folder_id: '',
+4 -6
View File
@@ -40,11 +40,9 @@
const entries = $derived(
raw.map((it): ResourceEntry => {
const isFile = it.resource_type === 'file';
// §14 provenance — prefer `created_by` (who put the item
// into the system) over the deprecated `owner_id`. Fall
// back to `owner_id` for pre-D7 rows whose `created_by`
// column wasn't backfilled.
const ownerId = it.resource.created_by ?? it.resource.owner_id ?? null;
// §14 provenance: `created_by` names who put the item into
// the system (Files browser / Favorites / Shared semantic).
const ownerId = it.resource.created_by ?? null;
return {
id: it.resource.id,
name: it.resource.name,
@@ -110,7 +108,7 @@
});
raw = reset ? page.items : [...raw, ...page.items];
cursor = page.next_cursor;
void owners.resolve(page.items.map((i) => i.resource.created_by ?? i.resource.owner_id));
void owners.resolve(page.items.map((i) => i.resource.created_by));
} catch (e) {
console.error('favorites: load error', e);
error = t('errors_loadFailed', 'Failed to load items');
@@ -41,7 +41,6 @@ function withOneFile() {
mime_type: 'image/png',
modified_at: 0,
name: 'photo.png',
owner_id: 'me',
created_by: 'me',
updated_by: 'me',
folder_id: 'root',
@@ -1798,7 +1798,7 @@
<span class="grid-meta__date">{relativeTimeAgo(folder.modified_at)}</span>
</div>
<div class="owner-cell">
{ownerLabel(folder.created_by ?? folder.owner_id, session.user?.id ?? null)}
{ownerLabel(folder.created_by, session.user?.id ?? null)}
</div>
<div class="type-cell">{t('files.file_types.folder', 'Folder')}</div>
<div class="size-cell">—</div>
@@ -1930,7 +1930,7 @@
{#if file.size != null}<span class="grid-meta__size">{formatBytes(file.size)}</span>{/if}
</div>
<div class="owner-cell">
{ownerLabel(file.created_by ?? file.owner_id, session.user?.id ?? null)}
{ownerLabel(file.created_by, session.user?.id ?? null)}
</div>
<div class="type-cell">{typeLabel(file.category)}</div>
<div class="size-cell">{file.size != null ? formatBytes(file.size) : ''}</div>
-2
View File
@@ -90,7 +90,6 @@ function fileItem(id: string, name: string) {
mime_type: 'text/plain',
modified_at: 0,
name,
owner_id: 'me',
created_by: 'me',
updated_by: 'me',
folder_id: 'home',
@@ -112,7 +111,6 @@ function folderItem(id: string, name: string) {
is_root: false,
modified_at: 0,
name,
owner_id: 'me',
created_by: 'me',
updated_by: 'me',
parent_id: 'home',
-1
View File
@@ -34,7 +34,6 @@ function photo(id: string) {
mime_type: 'image/jpeg',
modified_at: 0,
name: id + '.jpg',
owner_id: 'me',
created_by: 'me',
updated_by: 'me',
folder_id: 'home',
+5 -6
View File
@@ -42,11 +42,10 @@
const entries = $derived(
raw.map((it): ResourceEntry => {
const isFile = it.resource_type === 'file';
// §14 provenance — Recent's mental model is "who touched
// this recently", so `updated_by` (the last mutator) is
// preferred over `created_by` (who put it in). Fall back
// to `owner_id` for pre-D7 rows with no provenance.
const ownerId = it.resource.updated_by ?? it.resource.owner_id ?? null;
// §14 provenance: Recent's mental model is "who touched this
// recently", so `updated_by` (the last mutator) is the right
// signal — distinct from Favorites/Files which use `created_by`.
const ownerId = it.resource.updated_by ?? null;
return {
id: it.resource.id,
name: it.resource.name,
@@ -122,7 +121,7 @@
});
raw = reset ? page.items : [...raw, ...page.items];
cursor = page.next_cursor;
void owners.resolve(page.items.map((i) => i.resource.updated_by ?? i.resource.owner_id));
void owners.resolve(page.items.map((i) => i.resource.updated_by));
} catch (e) {
console.error('recent: load error', e);
error = t('errors_loadFailed', 'Failed to load items');
-1
View File
@@ -45,7 +45,6 @@ function withOneFile() {
mime_type: 'text/plain',
modified_at: 0,
name: 'notes.txt',
owner_id: 'me',
created_by: 'me',
updated_by: 'me',
folder_id: 'root',
-1
View File
@@ -46,7 +46,6 @@ function grantItem() {
is_root: false,
modified_at: 0,
name: 'Docs',
owner_id: 'me',
created_by: 'me',
updated_by: 'me',
parent_id: null,