question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Store files in the proper location on Windows.

See original GitHub issue
  • OS: Windows
  • Version of IPFS Desktop: 0.12.2

Describe the bug Installing IPFS Desktop on Windows results in folders in %USERPROFILE% as well as cache and DB files in the roaming profile.

To Reproduce Steps to reproduce the behavior:

  1. Install IPFS Desktop on Windows
  2. Notice that you have a .ipfs and .ipfs-desktop folder in %USERPROFILE% and %APPDATA/IPFS Desktop contains cache files, databases, blob storage, etc.

Expected behavior Cache files, file storage, databases, and per-machine configuration should all be stored in %LOCALAPPDATA%/ipfs/. Per user configuration (I’m not sure if IPFS has any of this, maybe the list of pinned files?) should be stored in %APPDATA%/ipfs/. Nothing should be stored in %USERPROFILE% (aka: %HOME%) unless the user *explicitly tells the app to do so such as via a save dialog box.

Additional context Both Linux and OSX also have environment variables that instruct applications where the appropriate place for files is. I believe it is called XDG_CONFIG though I’m not personally familiar with it.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
MicahZoltucommented, Oct 10, 2020

I submitted an issue to get go-homedir library fixed: https://github.com/mitchellh/go-homedir/issues/30

I believe there are other similar libraries that better support different data types so if the author of go-homedir is resistant to this change, perhaps switching go-ipfs to a different library would be the right course of action long term. Either way, migration will need to be handled still so the library getting fixed isn’t the final solution.


Main concern here is the cost of fixing Electron’s shortcomings in our code over time.

My opinionated advice here is to wait for upstream electron to fix the %APPDATA% vs %LOCALAPPDATA% problem.

My concern with this strategy is that this issue has been open with Electron for almost 4 years now, and until they fix it the default of Electron is to be a bad citizen. This means that IPFS Desktop will continue to be a bad citizen indefinitely, since there is no light at the end of the tunnel for Electron fixing the issue.

That being said, I understand your position and appreciate you clearly laying out why you are weakly opposed to it. I certainly don’t envy the maintainers of IPFS Desktop being put in this situation.


All in all, I agree with all 3 of your suggested paths forward. They are prudent and get things to a better place eventually without risking too much code complexity or breakage along the way.

2reactions
MicahZoltucommented, Oct 8, 2020

We could override the default (set custom IPFS_PATH on Windows, when it is missing from env) and point at something like %LOCALAPPDATA%/go-ipfs/.ipfs

A . prefix on Windows does not alter visibility and it causes some mild annoyances in Windows Explorer since you cannot set a folder to that name in some contexts. However, applications are free to do whatever they want within their subfolders of %LOCALAPPDATA% so if for some reason having a folder without a leading . is difficult then letting it stay I think is fine and still respects Windows folder hierarchy.

We could safely remove this directory by moving it to the directory with Electron app config ($XDG_CONFIG/IPFS Desktop on Linux is $HOME/.config/IPFS Desktop, and $user/AppData/Roaming/IPFS Desktop on Windows)

$user/AppData/Roaming should be %APPDATA%. It is configurable, and won’t always be a subdirectory of %USERPROFILE% nor will it necessarily be a sibling of %LOCALAPPDATA% (in fact, it is common to have them on different drives). Does IPFS currently use %APPDATA%, %LOCALAPPDATA%, and %USERPROFILE% or is it manually constructing those paths? If it is manually constructing those paths then that should be fixed as well.

Something to be aware of is that Electron’s default locations are bad and you should not assume that Electron will put data in the right place by default. Electron by default considers hundreds of megabytes of cache data to be “app config” and it stores it in a location that is network synced/backed up. Given this, I recommend moving the Electron stuff to %LOCALAPPDATA% since it can grow pretty large and is transient data (not actual user-configuration data).

In general, my advice is to use %LOCALAPPDATA% for everything as a default unless your application is specifically designed to support roaming/network synced configuration. I don’t know if IPFS is currently designed for synced user configuration, though it would be pretty cool if it was. In particular, I would like it if my list of pinned files was synced and when I switched computers IPFS would automatically fetch pinned items and remove pins from items I unpinned on another computer. However, I would not want the actual pinned content to live in a roaming location, just the hashes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

3 Better Ways to Store Your Files Than on the Desktop
The Windows desktop isn't meant to be a folder for your files. Here are some of the better options to store your files....
Read more >
How to Organize Computer Files - Home and Garden
Creating a folder can, in most cases, be done by right-clicking and selecting "New" and then "Folder," at which point you will be...
Read more >
Where Should I Save Files? - Computer Hope
On Windows computers, all document-related files (e.g., word processor and spreadsheet files) default to save in the My Documents folder ...
Read more >
Files save to OneDrive by default in Windows 10
Set where your files are saved · Select the OneDrive cloud icon in the notification area, at the far right of the taskbar....
Read more >
How to Set Default Document Folder Location in Windows
Windows 10 · Click the [Windows] button > choose "File Explorer." · From the left side panel, right-click "Documents" > choose "Properties." ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found