Skip to content

[PER-10780] Pick the file that has content, a size, not only the original format. - #1210

Open
aasandei-vsp wants to merge 2 commits into
mainfrom
PER-10780-show-only-file-with-size
Open

aasandei-vsp wants to merge 2 commits into
mainfrom
PER-10780-show-only-file-with-size

Conversation

@aasandei-vsp

@aasandei-vsp aasandei-vsp commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Stela can send multiple files per record with the original format. The web-app wouldn't check for content, but would pick the first file that has the original format, which sometimes is an empty one. This PR adds a check for the preview and data services to check if the file we are trying to preview or download actually has content. It seems we might need a follow-up with stela.

This is actually a fix(more of a gating) that is inferred, as I could not reproduce the bug locally.

Issue: PER-10780

Click here to view curated manual test cases # Manual test cases — regression for picking files in the viewer and downloads

Nothing should look different. This change only affects which file the app picks for a record, so every viewer and download should behave exactly as before.


Full-screen viewer ⭐

Images

  1. Double-click an image you have already uploaded.
    • EXPECTED: The photo shows full size and you can zoom in and pan.
  2. Press the right arrow to move to another image.
    • EXPECTED: The photo shows and you can zoom it.
  3. Press the left arrow to go back.
    • EXPECTED: The initial image shows again, not blank.

Documents

  1. Double-click a docx file.
    • EXPECTED: The PDF renders inside the viewer.

Media

  1. Open a video.
    • EXPECTED: The video loads and plays.
  2. Open an mp3 file.
    • EXPECTED: The audio player loads and plays.

Download ⭐

From the full-screen viewer

  1. Open an image and use the download button under the metadata.
    • EXPECTED: The image downloads, opens, and is the same size as the original upload.
  2. Open a docx file and open the download options.
    • EXPECTED: Both the original and the converted format are listed. Each downloads a file of that type that opens.

From the file list

  1. Select the pdf version of the docx and download it from the file list controls.
    • EXPECTED: The PDF downloads and opens.
  2. Open the actions menu on video and choose Download.
    • EXPECTED: The video downloads and plays.

Shared and public views

(same viewer on other routes, cheap sanity checks)

Share link

  1. Create a share link for a folder, open it in a private window and double-click an image.
    • EXPECTED: The photo shows and can be zoomed.

…ontent

Some files receive from stela multiple originals, one being an empty placeholder
and the other one being the real content. On web, we were not checking whether the
file we were picking had content, but now we make sure to filter the correct one
only for preview-ing.

Issue: PER-10780
…ne marked as original

Stela is sending multiple files with the format original and up until now
we would just take the first file marked as original, instead of checking it had content.
Now in the data service and the file viewer, we are actually checking that the file
that gets to be previewed has content.

Issue: PER-10780
@aasandei-vsp aasandei-vsp self-assigned this Oct 9, 2026
@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 53.73%. Comparing base (05374e1) to head (6e21cd3).
⚠️ Report is 30 commits behind head on main.

Files with missing lines Patch % Lines
src/app/models/get-access-file.ts 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1210      +/-   ##
==========================================
+ Coverage   53.64%   53.73%   +0.09%     
==========================================
  Files         368      368              
  Lines       12925    12928       +3     
  Branches     2363     2365       +2     
==========================================
+ Hits         6933     6947      +14     
+ Misses       5753     5744       -9     
+ Partials      239      237       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

File-selection fallbacks, unavailable-file handling, and incomplete fixture data have unresolved issues.

4 open findings
What changed in this PR

This PR updates preview and download file selection to prefer files with retrievable content instead of empty originals.

Changes:

  • Adds file retrievability and prioritization helpers.
  • Applies selection logic to downloads and viewer previews.
  • Adds regression tests for duplicate and failed files.
File Summary
src/​app/​shared/​services/​data/​data.service.ts Updates download selection; unavailable typed or original files still need safe handling.
src/​app/​shared/​services/​data/​data.service.spec.ts Adds download-selection tests.
src/​app/​models/​get-access-file.ts Adds file-selection helpers; failed preferred entries can still be selected.
src/​app/​models/​get-access-file.spec.ts Tests prioritization behavior.
src/​app/​file-browser/​components/​file-viewer/​file-viewer.component.ts Uses original-file selection; empty originals can block fallback previews.
src/​app/​file-browser/​components/​file-viewer/​file-viewer.component.spec.ts Adds preview-selection tests and requires valid fixture sizes.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

}

function hasRetrievableContent(file: PermanentFile): boolean {
return Boolean(file.fileURL) && file.size !== null && file.size !== undefined;
Comment on lines +34 to 39
const files = prioritizeRetrievableFiles(record?.FileVOs ?? []);
return (
getArchivematicaAccess(files) ||
getPrioritizedConvertedFile(files) ||
files[0]
);
Comment on lines +608 to +610
return prioritizeRetrievableFiles(fileItem.FileVOs).find(
(file) => file.type === type,
);
}

return find(fileItem.FileVOs, { format: 'file.format.original' });
return GetOriginalFile(fileItem);
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.

2 participants