Skip to content

Files mis-bucketed into other: folder upload / folder-sync route mixed content to one bucket instead of per-type #11

@ehsan6sha

Description

@ehsan6sha

Summary

Files of recognized types end up in the other bucket instead of their type bucket (audio, documents, …). On one account: audio has 2 objects while other has 147 — including .mp3/.wav audio and .md documents. This is a categorization/routing bug, not data loss — the files are intact in other.

Root cause

The per-file classifier is correct: FileCategory.fromExtension maps mp3/wav -> audio, md -> documents (lib/core/services/file_service.dart). The main per-file upload paths use it correctly:

  • lib/app/app.dart:389,400 -> remoteBucket: category.bucketName
  • lib/features/browser/screens/file_browser_screen.dart:2285 (single file), :2323 (folder, per-file)

But two routes assign a single fixed bucket to a whole batch, bypassing per-file classification:

  1. Stale "mixed -> other" relic. _uploadFolder (file_browser_screen.dart:2310) carries the comment // Determine bucket - use ''other'' for mixed folder contents over code that now classifies per file. It documents an earlier behavior (reworked around 63cfcb4, 2025-12-14 "folder sync") where mixed folders were dumped into other. Files uploaded by that earlier version remain in other.
  2. Folder/background sync uploads to a configured bucket. background_sync_service._executeUploadTask (background_sync_service.dart:143-153) uploads to inputData[''bucket''] — a bucket fixed by the sync task, not per-file. A folder-sync pointed at a target bucket routes ALL its files there regardless of type.

Impact

  • Type-based browsing (Audio/Documents tabs) shows the type buckets near-empty while the files sit in other.
  • It also muddies recovery: a near-empty audio bucket with a broken forest looks like data loss when the real audio is safe in other.

Observed (one account)

audio=2 objects, documents~75, other=147. .mp3, .wav, and .md files visible under other.

Suggested fixes (later, after recovery)

  • Remove the stale "mixed -> other" relic; ensure every upload path classifies per file.
  • Folder-sync: make the destination explicit (per-file categories vs one bucket) and surface it in the UI.
  • Add a MIME fallback (lookupMimeType, already imported) and handle no-extension files — FileCategory.fromPath does path.split(''.'').last, so an extension-less name returns the whole filename -> other.
  • Optional: a re-bucketing/migration tool to move mis-filed files from other to the correct type buckets.

Not data loss — files are intact in other; this is purely which bucket they are filed under.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions