-
-
Notifications
You must be signed in to change notification settings - Fork 733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent sqlite db to overwrite while installing my ElectronNet application #743
Comments
Can you create a full MWE e.g., as a GitHub repository? It would help to see what you actually do and if this is indeed a bug. |
Let me try to give you the more detail. There is only one page which simply displays the list of users (dummy users) from "Users" table from Sqlite db. `
` and in the appsettings.json file, I have defined the connection string like this - So when you run the application, "FluentMigrator" will create the table schema and insert the dummy data using following code. `[Migration(20230318)]
}` Now in my Visual Studio solution, I have mark this sqlite db file as "Embed Resource" as shown in below image. Basically what I am trying to do is - when I will first time install this electron app in client machine at that time I want electron setup to copy sqlite db file in client machine. Now after few days, let say If I have released some new feature then in the second installation I don't want electron setup will copy that sqlite db file because it was already there in the client machine. And I don't want electron setup will replace that file on subsequent installation. Can anybody helped here where to look for that @GregorBiswanger? Write now I am trying to control that by writing below code in "main.js" file. But that's approach not working. `const fs = require('fs'); // Get the installation directory // Check if the database file already exists |
Well, again, what I'm asking is a simple reproducible with a GitHub repository. If I understood the OP the problem is not at all related to sqlite (not sure why this was brought up then), but rather the usage of your main.js. So again, just provide a MWE showing your exact problem - once we have a reproducible we can take care of it. |
@krishrana17 , How do you package the electron application? When you use Visual studio project installer, it has the capability to create new or replace option when installed freshly or updating it to the existing application. |
I am developing an Electron.NET application using .NET Core 6 and I want to prevent my SQLite database file from being overwritten during the installation process if it already exists. I have added the necessary code to my manually created 'main.js' file to check for the existence of the file and copy it only if it doesn't exist. However, when I build the package using 'electronize build /target win', the code in my 'main.js' file is not reflected in the built package. Is this a bug or am I missing something?
`const fs = require('fs');
const path = require('path');
const { app } = require('electron');
// Get the installation directory
const appPath = app.getPath('exe');
const installDir = path.dirname(appPath);
// Check if the database file already exists
const dbFile = path.join(installDir, 'mydb.sqlite');
if (!fs.existsSync(dbFile)) {
const resourcePath = path.join(__dirname, 'mydb.sqlite');
fs.copyFileSync(resourcePath, dbFile);
}`
The text was updated successfully, but these errors were encountered: