Mailspring Windows: does not follow knownfolders rule in windows

Description

When asking to which folder an attachment should be saved, mailspring shows the (probably hardcoded ?) folder
C:\USERS\username\DOWNLOADS

This should not happen, Windows has since Vista(!) the “KnownFolders” class which points to the current location:

Windows Vista introduces new storage scenarios and a new user profile namespace. To address these new factors, the older system of referring to standard folders by a CSIDL value has been replaced. As of Windows Vista, those folders are referenced by a new set of GUID values called Known Folder IDs.

To Reproduce…

Steps to reproduce the behavior:

  1. Downloads folder is not in the C:USERS\username\Downloads location but elsewhere (e.g. Onedrive, on another physical drive)
    2.Click an attachment and save it in the shown Downloads folder
  2. It shows up under C:\USERS\username\Downloads

Expected Behavior

The file is saved in the location where all the other downloads end up

|OS Name|Microsoft Windows 10 Education|
|Version|10.0.18363 Build 18363|

  • Mailspring Version:1.80 8983dca2

Good catch :slight_smile: Looks like it’s hard-coded to use %USERPROFILE%\Downloads if it exists, otherwise falling back to the temp directory:

Getting the path of a known folder is tricky in Node.js… There’s no native JS API for it so you need to call the native Win32 SHGetKnownFolderPath API (eg. using ffi). Something like this: