Skip to content
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

[auth] [linux] ente data in user home - infinite loading if ~/ente file exists #2564

Open
nktnet1 opened this issue Jul 28, 2024 · 1 comment
Labels
- auth Relates to Ente Auth --desktop Plaftorm is desktop

Comments

@nktnet1
Copy link

nktnet1 commented Jul 28, 2024

Description

When using ente, a directory and sqlite3 database is created in the user's home folder:

$ file ~/ente/.ente.authenticator.db
/home/nktnet/ente/.ente.authenticator.db: SQLite 3.x database, user version 1, last written using SQLite version 3046000, file counter 2, database pages 4, cookie 0x1, schema 4, UTF-8, version-valid-for 2

Deleting/renaming the directory means that user details are lost.

Worse, having a file with path ~/ente instead of a directory means that ente-auth will load infinitely (as it cannot read from the sqlite database).

A better way to store user configurations would be to follow the standards set by XDG Base Directory, whereby this sqlite database file is stored in $XDG_DATA_HOME, e.g.

${XDG_DATA_HOME}/ente/.ente.authenticator.db         # which defaults to:
${HOME}/.local/share/.ente/.ente.authenticator.db

This is similar to #2563, where ente is using ~/temp instead of ${XDG_CACHE_HOME}/ente, leading to user files being unintentionally deleted.

The code in question is below:

class AuthenticatorDB {
static const _databaseName = "ente.authenticator.db";
static const _databaseVersion = 1;
static const entityTable = 'entities';
AuthenticatorDB._privateConstructor();
static final AuthenticatorDB instance = AuthenticatorDB._privateConstructor();
static Future<Database>? _dbFuture;
Future<Database> get database async {
_dbFuture ??= _initDatabase();
return _dbFuture!;
}
Future<Database> _initDatabase() async {
if (Platform.isWindows || Platform.isLinux) {
var databaseFactory = databaseFactoryFfi;
return await databaseFactory.openDatabase(
await DirectoryUtils.getDatabasePath(_databaseName),
options: OpenDatabaseOptions(
version: _databaseVersion,
onCreate: _onCreate,
),
);
}

Thanks ~

Version

v3.0.17

What product are you using?

Ente Auth (installed ente-auth-bin from AUR)

What platform are you using?

Desktop - Linux

@nktnet1 nktnet1 added the triage label Jul 28, 2024
@nktnet1 nktnet1 changed the title [auth] [linux] ente storing config in user home directory [auth] [linux] ente storing config in user home directory - infinite loading if ~/ente exists Jul 28, 2024
@nktnet1 nktnet1 changed the title [auth] [linux] ente storing config in user home directory - infinite loading if ~/ente exists [auth] [linux] ente config in user home - infinite loading if ~/ente exists Jul 28, 2024
@nktnet1 nktnet1 changed the title [auth] [linux] ente config in user home - infinite loading if ~/ente exists [auth] [linux] ente data in user home - infinite loading if ~/ente file exists Jul 28, 2024
@ua741 ua741 added - auth Relates to Ente Auth --desktop Plaftorm is desktop and removed triage labels Aug 24, 2024
@prateekmedia
Copy link
Member

Will be fixed in the next version, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- auth Relates to Ente Auth --desktop Plaftorm is desktop
Projects
None yet
Development

No branches or pull requests

3 participants