Skip to content

Added more robust Error handling and fallback to other Download options if FileSystemwritableFilestream does not work#2438

Merged
monkeyiq merged 3 commits intofilesender:developmentfrom
dkfz-itcf:fswf-fallback
Dec 31, 2025
Merged

Added more robust Error handling and fallback to other Download options if FileSystemwritableFilestream does not work#2438
monkeyiq merged 3 commits intofilesender:developmentfrom
dkfz-itcf:fswf-fallback

Conversation

@flowdnb
Copy link
Copy Markdown
Contributor

@flowdnb flowdnb commented Oct 22, 2025

Proof-of-concept implementation for #2420

…ns if FileSystemwritableFilestream does not work.
@monkeyiq monkeyiq self-assigned this Oct 24, 2025
@monkeyiq
Copy link
Copy Markdown
Contributor

monkeyiq commented Nov 6, 2025

It may be that an inline fallback is needed here to work nicely.

It may not be easy or robust to be able to check if you have the "file editing" permission from javascript. If I force file editing off in Chrome (Settings, Privacy, Permissions, File Editing) and then change this function in filesender-config.js.php to just return false then the fallbacks are triggered and I can download a file.

So another option would be to allow an admin to force this to off if their browser policy is to disallow it. That is assuming that the permission can not be reliably tested for in JS.

window.filesender.config.isFileSystemWritableFileStreamAvailableForDownload = function() {
return false;
//    return 'showSaveFilePicker' in window;
};

@monkeyiq
Copy link
Copy Markdown
Contributor

monkeyiq commented Nov 6, 2025

An alternate I have been testing is waiting to get to decryptDownloadToBlobSink and checking for the NotAllowedError at that stage and if present then recalling decryptDownload with FSWF support forced to off. I will take a closer look at the options as doing it this alternate way is a bit loopy. It works ok in the browser from the user perspective, if decryptDownload is updated to not reprompt for the password on recursive call.

Though the alternate I have might be more kludgey than moving to the await calls up front as in this PR. Good to explore options though. :)

A real shame there doesn't seem to be a sync API to ask "do I have permission to call window.showSaveFilePicker".

@monkeyiq
Copy link
Copy Markdown
Contributor

monkeyiq commented Nov 6, 2025

Thank you for making the pull request!

@monkeyiq
Copy link
Copy Markdown
Contributor

As there are a number of changes already in development I think I will delay merging this until after the next release. I might make the next release 2.60 which will have the database updates and performance improvements in it. After that and a period of time for possible bugfix updates then I will turn attention to merging this and retesting the download paths with it.

@monkeyiq monkeyiq self-requested a review November 16, 2025 00:39
@flowdnb
Copy link
Copy Markdown
Contributor Author

flowdnb commented Nov 18, 2025

Thank you for the thorough review and for considering this PR in the next releases plan.

@flowdnb flowdnb marked this pull request as ready for review November 18, 2025 10:54
@monkeyiq
Copy link
Copy Markdown
Contributor

release 2.60 (and release 2.61 due to release process) are now out. 2.61 on the 16th. If things remain quiet on the 2.61 front I will look at merging this in the next week or two.

Copy link
Copy Markdown
Contributor

@monkeyiq monkeyiq left a comment

Choose a reason for hiding this comment

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

I can probably revert the two above changes. I've been testing this out a bit more today.

window.filesender.log("downloadAndDecryptChunk(progress) chunkid " + chunkid
+ " loaded " + evt.loaded + " of total " + evt.total );
if (evt.lengthComputable || evt.loaded) {
if (evt.lengthComputable) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think we want to revert this change #2324

password_hash_iterations: encryption_details.password_hash_iterations,
client_entropy: encryption_details.client_entropy,
};
var keydesc = JSON.stringify(pbkdf2details);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We want to use pbkdf2details here to avoid having to make the key again for different files in the same transfer.

@monkeyiq
Copy link
Copy Markdown
Contributor

monkeyiq commented Dec 31, 2025

I see a regression on Safari. Downloading an encrypted file goes from showing the download % on the download page to downloading everything in the background with no progress and only showing on completed. I haven't dug into the diagnostics to see why this is the case yet. Just an A/B of this PR vs development with a macos client + safari.

EDIT: Actually no. I had a branch without the evt. revert in it that I readded here. With that Safari is fine.

@monkeyiq monkeyiq merged commit 5b5225d into filesender:development Dec 31, 2025
5 checks passed
@monkeyiq
Copy link
Copy Markdown
Contributor

This is in 2.62. Thanks again for investigating things and making this PR!

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