You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When selecting the sample database, we only use a space that is fully stored in the database. So all of the space folders inside the VAR_FOLDER should be removed. Currently we are keeping them, which means that the folder might keep accumulating unused spaces.
The text was updated successfully, but these errors were encountered:
Hi @amoury, thanks for your interest. Basically, we currently have two layers that deal with persistence:
A database handled by lowdb.
The file system, which is handled by electron, with everything inside the VAR_FOLDER path.
To use the sample database, the setDatabase action creator (in actions/developer.js) is called, which then calls the following method in the electron.js file:
// called when setting the database
ipcMain.on(SET_DATABASE_CHANNEL, async (event, payload) => {
try {
// get space from local db
db.setState(payload).write();
const database = db.getState();
mainWindow.webContents.send(SET_DATABASE_CHANNEL, database);
} catch (err) {
logger.error(err);
mainWindow.webContents.send(SET_DATABASE_CHANNEL, null);
}
});
The problem is that setDatabase overrides the database with whatever the database variable contains, which is usually an array under the key spaces and an object under the key user (An example can be seen in sample.json. What is does not do is free up the VAR_FOLDER, which contains a directory per space.
A first step would be to enhance the code above to get a list of the folders inside VAR_FOLDER. These folders have the name of the id property of the space. So then we can compare that list, with the ids of the space array in the database variable and then use rimraf to remove any folder that is not present in the space array.
Does that make sense? Thanks again for helping out!
When selecting the sample database, we only use a space that is fully stored in the database. So all of the space folders inside the
VAR_FOLDER
should be removed. Currently we are keeping them, which means that the folder might keep accumulating unused spaces.The text was updated successfully, but these errors were encountered: