mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-05-25 02:32:11 +00:00
fix smaller issues
This commit is contained in:
parent
4dbc369003
commit
61979aedcb
5 changed files with 14 additions and 16 deletions
|
|
@ -277,7 +277,7 @@ class GroupsDao extends DatabaseAccessor<TwonlyDB> with _$GroupsDaoMixin {
|
|||
groups.groupId.equalsExp(groupMembers.groupId),
|
||||
),
|
||||
],
|
||||
)..where(groups.isDirectChat.isNull()));
|
||||
)..where(groups.isDirectChat.equals(false)));
|
||||
return query.map((row) => row.readTable(groupMembers)).get();
|
||||
} catch (e) {
|
||||
Log.error(e);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import 'package:background_downloader/background_downloader.dart';
|
|||
import 'package:clock/clock.dart' as clock;
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:mutex/mutex.dart';
|
||||
import 'package:twonly/core/bridge.dart' as bridge;
|
||||
import 'package:twonly/core/bridge/wrapper/backup.dart';
|
||||
import 'package:twonly/globals.dart';
|
||||
import 'package:twonly/locator.dart';
|
||||
|
|
@ -307,17 +306,6 @@ class BackupService {
|
|||
);
|
||||
|
||||
await deleteLocalUserData();
|
||||
try {
|
||||
await bridge.initializeTwonlyFlutter(
|
||||
config: bridge.InitConfig(
|
||||
databaseDir: AppEnvironment.supportDir,
|
||||
dataDir: AppEnvironment.supportDir,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
Log.error(e);
|
||||
return RecoveryError.unkownError;
|
||||
}
|
||||
await KeyValueStore.put(KeyValueKeys.backupRecoveryState, state.toJson());
|
||||
return _nextBackupStage();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,11 @@ import 'package:twonly/src/utils/exclusive_access.utils.dart';
|
|||
import 'package:twonly/src/utils/log.dart';
|
||||
|
||||
class KeyValueStore {
|
||||
static final Mutex _mutex = Mutex();
|
||||
static final Map<String, Mutex> _mutexes = {};
|
||||
|
||||
static Mutex _getMutex(String key) {
|
||||
return _mutexes.putIfAbsent(key, Mutex.new);
|
||||
}
|
||||
|
||||
static Future<File> _getFilePath(String key) async {
|
||||
return File('${AppEnvironment.supportDir}/keyvalue/$key.json');
|
||||
|
|
@ -16,7 +20,7 @@ class KeyValueStore {
|
|||
static Future<T> _exclusive<T>(String key, Future<T> Function() action) {
|
||||
return exclusiveAccess(
|
||||
lockName: 'keyvalue-$key',
|
||||
mutex: _mutex,
|
||||
mutex: _getMutex(key),
|
||||
action: action,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,6 +134,7 @@ impl BackupArchive {
|
|||
for (file_name, target_dir, is_db, _) in Self::get_backup_files(ctx, &key_manager)? {
|
||||
let src = restore_temp_dir.join(file_name);
|
||||
if src.exists() {
|
||||
std::fs::create_dir_all(&target_dir)?;
|
||||
let dst = target_dir.join(file_name);
|
||||
if is_db {
|
||||
// Remove existing database and its temporary files (WAL, SHM)
|
||||
|
|
|
|||
|
|
@ -82,10 +82,15 @@ impl Context {
|
|||
|
||||
async fn init_common(config: InitConfig, is_flutter: bool) -> Result<()> {
|
||||
if GLOBAL_CONTEXT.initialized() {
|
||||
tracing::info!("twonly already initialized.");
|
||||
tracing::info!("twonly already initialized. Ensuring storage directories exist.");
|
||||
std::fs::create_dir_all(&config.database_dir)?;
|
||||
std::fs::create_dir_all(&config.data_dir)?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
std::fs::create_dir_all(&config.database_dir)?;
|
||||
std::fs::create_dir_all(&config.data_dir)?;
|
||||
|
||||
let log_dir = PathBuf::from(&config.data_dir).join("log");
|
||||
init_tracing(&log_dir, is_flutter).await;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue