Skip to content

feat(drive): download folder as archive - #11005

Open
AitiX wants to merge 1 commit into
hcengineering:developfrom
AitiX:feature/drive-folder-download-archive
Open

feat(drive): download folder as archive#11005
AitiX wants to merge 1 commit into
hcengineering:developfrom
AitiX:feature/drive-folder-download-archive

Conversation

@AitiX

@AitiX AitiX commented Aug 12, 2026

Copy link
Copy Markdown

Description

Adds a Download as archive action for folders in the Drive module. Previously only
individual files could be downloaded; folders with many files (e.g. build artifacts)
had to be fetched one file at a time.

The action walks the folder tree through the platform client, fetches every file blob
and packs everything into a single <folder name>.zip on the client, preserving the
relative folder structure inside the archive.

Implementation notes

  • New action drive.action.DownloadFolder / drive.actionImpl.DownloadFolder,
    registered for drive.class.Folder next to the existing file Download action
    (same category, tools group, context + browser modes).
  • Traversal (plugins/drive-resources/src/archive.ts): recursive
    client.findAll over drive.class.File (with $lookup of the current
    FileVersion) and drive.class.Folder, sorted by title for deterministic
    archives. A visited-set guards against cycles, and duplicate titles within one
    folder get a numeric suffix.
  • Blob access reuses getFileUrl from @hcengineering/presentation (the same
    URL the file Download action uses) and plain fetch, matching how
    getJsonOrEmpty fetches blobs elsewhere in the platform.
  • Zip library: fflate (^0.8.2), added
    to @hcengineering/drive-resources. No workspace package currently depends on a
    zip library directly (jszip appears in the lockfile only as a transitive
    dependency of docx tooling), so the smallest streaming option was chosen.
    Entries are added via ZipPassThrough (store, no re-compression): Drive blobs are
    typically already compressed or incompressible (archives, media, build artifacts),
    so this keeps CPU usage minimal while still producing a standard zip.
  • Files are fetched sequentially; the archive is assembled in memory and saved via a
    temporary object URL. Empty folders produce no download. Errors are reported through
    setPlatformStatus(unknownError(...)), consistent with other drive-resources utils.
  • Localization: new DownloadAsArchive string (en: "Download as archive",
    ru: "Скачать архивом"). Other locales fall back to English, matching existing
    partially-translated keys in drive-assets.

Changed files

  • models/drive/src/index.ts — register the folder action
  • models/drive/src/plugin.tsaction.DownloadFolder, actionImpl.DownloadFolder ids
  • plugins/drive-resources/src/archive.ts — new: traversal + zip + save
  • plugins/drive-resources/src/index.tsDownloadFolder action implementation
  • plugins/drive-resources/src/plugin.tsDownloadAsArchive string id
  • plugins/drive-resources/package.json — add fflate
  • plugins/drive-assets/lang/en.json, plugins/drive-assets/lang/ru.json — new string
  • common/config/rush/pnpm-lock.yaml — lockfile update for fflate

How to test

  1. Open a workspace with the Drive application enabled.
  2. Create a drive, add a folder with a few files and at least one nested subfolder
    with files (mixed types; ideally also two files with the same name in one folder).
  3. Right-click the folder (or use the ... menu) → Download as archive.
  4. A <folder name>.zip download should start; after extraction the content must
    mirror the Drive folder structure, including nested subfolders.
  5. Verify an empty folder triggers no download, and a folder whose name contains
    / or \ still produces a valid archive name.
  6. Regression: file Download, folder Rename/Delete/Move actions
    still work.

Checklist

  • Affected packages compile (rush build --to @hcengineering/model-drive --to @hcengineering/drive-resources)
  • Localized strings added (en, ru)
  • Screenshots / screencast (to attach when opening the PR)

@AitiX
AitiX force-pushed the feature/drive-folder-download-archive branch from f6d47f6 to 5054d15 Compare August 12, 2026 12:36
@AitiX
AitiX changed the base branch from main to develop August 12, 2026 12:38
Add a 'Download as archive' action for Drive folders. The action walks
the folder tree, fetches every file blob and packs them into a single
zip on the client (fflate, store mode), preserving the relative folder
structure. Localized for en and ru.

Signed-off-by: Alexander Ilyenko <alexander_ilyenko@outlook.com>
@AitiX
AitiX force-pushed the feature/drive-folder-download-archive branch from 5054d15 to 90ebb78 Compare August 12, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant