Electron creating various folders and files in my directory

Asked

Viewed 162 times

0

I am developing an application with Electron where I need to store some important data in a directory that I created in %APPDATA%.

The problem is that whenever I create this folder (I create using fs.mkdirSync), several files and folders are created within it at once. See the files that are created below:

AppData/Roaming/myFolder/  <---¬
    myOtherFolder/         <---l-----[Essas duas pastas são as únicas que eu crio]
    blob_storage/
    Cache/
    Code Cache/
    Dictionaries/
    FontLookupTableCache/
    GPUCache/
    Local Storage/
    Session Storage/
    Network Persistent State
    Preferences

What are these folders and files created? How can I prevent this so that it gets only the two folders I created?

  • These are folders of Electron do not recommend removing.

  • @Anittadeveloper I know it’s the Electron folders, but I want to know how I can make them not be created in the directory where I store the data? The directory I use to store the data is not the same where I run the Electron application. Have some way to make folders be created in another location?

  • I think this is not necessary, because there would be conflict of Electron finds the files.

  • @Anittadeveloper I really need this folder cleaned only with the files I create myself. Please help me with a solution to solve this problem.

  • I don’t recommend erasing them.

  • @Anittadeveloper I don’t want to delete, I just want them to go somewhere other than my folder with the data I want, got it?

  • Edited response with details on how to change the location of Chromium folders.

Show 2 more comments

1 answer

4

The Electron, as I said before in a commenting, is based on Chromium, as well as Chrome, Opera, Bravo, etc.

So the application created in HTML+CSS+JS is actually a hybrid application, IE, your program is a browser "disguised as a normal program", these folders are all used by the technologies you have in engines of Chromium, see Devtools:

aplicativo electron

To change the location you need to use app.setPath(name, path) using the value of name as userData:

 app.setPath('userData', '/pasta/foo/bar');

Being /pasta/foo/bar the new location of these folders, of course it is an example. However I must make it clear that the best place to keep temporary files is in the user folder, so I see no reason to change, what you can do if you really want to change (which I insist seems dispensable) is to take the value of userData with app.getPath('userData') and apply as sub-folder:

const userData = app.setPath('userData', '/pasta/foo/bar');

app.setPath('userData', `${userData}/chromium`);

I haven’t tested, but I may have to create the folder manually, so if it doesn’t work:

var fs = require('fs');

const userData = app.setPath('userData', '/pasta/foo/bar');

try {
    fs.mkdirSync(`${userData}/chromium`);
} catch (ee) {
    if (ee.code !== 'EEXIST') {
        throw e; //Se o erro não for sobre existir então irá emitir um erro e seu programa não irá iniciar
    }
}

app.setPath('userData', `${userData}/chromium`);

Note: You can even erase, but the engines will generate again and you can be sure that there are folders that haven’t appeared yet because your application hasn’t used things like:

I did not find details of all folders, but here goes almost everything:

  • blob_storage probably to control the blobs generated as with the use of the API Blob or URL.createObjectURL

  • Cache contain HTTP request caching (it depends on how you configure your project)

  • Code Cache this I do not know how it works for sure, but it seems that are caches of structures JS and wasm specific of some sites, not found sources

  • Dictionaries dictionaries for spell checker

  • FontLookupTableCache - I’ll edit it soon, it looks like it’s

  • GPUCache cache used by the program for GPU use

  • Local Storage for use of the API localStorage

  • Session Storage for use of the sessionStorage API

  • Network Persistent State probably to keep the persistence settings for HTTP requests

  • Preferences all preferences configured from browser/program

Summing up is only for control of own embedded browser, you yourself will not use them fully, will only use "indirectly"

  • William if they are only temporary files, why don’t they disappear and why don’t they stay in the folder TEMP?

  • Hey William, I tested this method and actually removed almost all folders from my directory. The problem is that the folder Dictionaries is still created there. What do I do about it? I want my directory clear without any of these Chromium folders.

  • @Jeanextreme002 no, the temp folder can usually be cleaned by several programs, which can imply problems in your program’s system, it is better that the program itself manages the caches.

  • @Jeanextreme002 I will see about the Dictionaries, but I must point out again, it is not necessary to worry about changing the folders, you can do, but it is more perfumery ... ps: I will search about the Dictionaries

  • Guilherme, did you find out about this folder Dictionaries? Know how to remove it?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.