deltachat-core-rust icon indicating copy to clipboard operation
deltachat-core-rust copied to clipboard

feat: Use random filenames for blobstorage (#4309)

Open iequidoo opened this issue 2 years ago • 6 comments

Based on #5495

See commit messages. See also the discussion here: https://github.com/deltachat/deltachat-core-rust/pull/4555.

Close #4309 Fix #5338

iequidoo avatar Jul 27 '23 20:07 iequidoo

thinking it over again, forcing random file name in blob-directory will worsen UX at least on deltachat-desktop, at least currently:

on desktop, currently, eg. a pdf-reader is opened without the file being copied, the pdf-reader will show the filename then - and there, sth. as one-sheet.pdf or one-sheet-12345678.pdf is better than 1234567812345678.pdf. cmp eg the following pdf viewer on macos - the title would become sth. totally random with this pr:

Screenshot 2023-08-04 at 20 19 27

i known, the idea is that all files should be copied before being accessed from external apps, however, we're not there yet on any UI; most visible, however it seems to be on desktop, cc @Simon-Laux

so, as the filename in the blob-directory does not have a meaning anyways and we're anyways have no consistency there, it would remove pressure from UIs and simplify getting this pr to stable if we keep filename generation as is (or maybe always add the random number so that it is more visible where the "wrong" filenames are used).

this pr could add only add the save-function, use correct names on forwarding, and what else is done here (@iequidoo i find pr descriptions as "some discussions here and there" without some additional words hard for reviewers, it would be good to always have at least a handful sentences in your own words about reasonings, effects, successor of etc)

as a side-effect, this would keep debugging blob-dir simple :)

when UI are adapted to the new API, we can think over to use completely random file names.

r10s avatar Aug 04 '23 18:08 r10s

The main tracking issue for this PR is #4309

This PR is not meant to be a next step at this point, see my comment at https://github.com/deltachat/deltachat-core-rust/issues/4309#issuecomment-1641359688 We indeed first need to adapt the UIs to avoid opening the files directly from the blobstore. Desktop is currently not even using the filename for the Save As dialog: https://github.com/deltachat/deltachat-desktop/issues/3330

link2xt avatar Aug 04 '23 18:08 link2xt

@iequidoo i find pr descriptions as "some discussions here and there" without some additional words hard for reviewers, it would be good to always have at least a handful sentences in your own words about reasonings, effects, successor of etc

Ok, i will better improve commit messages, i prefer putting everything there and use PR descriptions just for additional info.

As for dc_msg_get_file(), i can implement what @link2xt suggested:

dc_msg_get_file API should create a temporary directory inside the blobdir, save a copy with unmangled filename, and return its path. In the housekeeping we regularly clear these directories. This API is kept for compatibility, but deprecated.

but then we need to add some new call like dc_msg_get_filedata_path() which will return the path of a file with mangled name (but with an original extension) to avoid unnecessary copying.

iequidoo avatar Aug 05 '23 03:08 iequidoo

Also i can just remove the last commit so that there will be random suffixes, but not whole filenames. Anyway now we can get files with random suffixes from dc_msg_get_file() in case of filename duplication

iequidoo avatar Aug 05 '23 03:08 iequidoo

Removed the last commit to unblock merging this

iequidoo avatar Jan 24 '24 02:01 iequidoo

test_verified_oneonone_chat_enable_disable suddenly failed: https://github.com/deltachat/deltachat-core-rust/actions/runs/8255079330/job/22580740709?pr=4583

iequidoo avatar Mar 13 '24 02:03 iequidoo