mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-02 14:56:20 +01:00
Setting eagerError may cause the transaction to end before all future returns
This commit is contained in:
parent
2df27502f1
commit
84264dad20
1 changed files with 26 additions and 30 deletions
|
@ -264,36 +264,32 @@ class FileSqliteCacheUpdater {
|
||||||
.map((r) => MapEntry(r.read(db.files.fileId)!, r.read(db.files.rowId)!))
|
.map((r) => MapEntry(r.read(db.files.fileId)!, r.read(db.files.rowId)!))
|
||||||
.get());
|
.get());
|
||||||
|
|
||||||
await Future.wait(
|
await Future.wait(sqlFiles.map((f) async {
|
||||||
sqlFiles.map((f) async {
|
var rowId = fileRowIdMap[f.file.fileId.value];
|
||||||
var rowId = fileRowIdMap[f.file.fileId.value];
|
if (rowId != null) {
|
||||||
if (rowId != null) {
|
// shared file that exists in other accounts
|
||||||
// shared file that exists in other accounts
|
} else {
|
||||||
} else {
|
final dbFile = await db.into(db.files).insertReturning(
|
||||||
final dbFile = await db.into(db.files).insertReturning(
|
f.file.copyWith(server: sql.Value(dbAccount.server)),
|
||||||
f.file.copyWith(server: sql.Value(dbAccount.server)),
|
);
|
||||||
);
|
rowId = dbFile.rowId;
|
||||||
rowId = dbFile.rowId;
|
}
|
||||||
}
|
final dbAccountFile =
|
||||||
final dbAccountFile = await db
|
await db.into(db.accountFiles).insertReturning(f.accountFile.copyWith(
|
||||||
.into(db.accountFiles)
|
account: sql.Value(dbAccount.rowId),
|
||||||
.insertReturning(f.accountFile.copyWith(
|
file: sql.Value(rowId),
|
||||||
account: sql.Value(dbAccount.rowId),
|
));
|
||||||
file: sql.Value(rowId),
|
if (f.image != null) {
|
||||||
));
|
await db.into(db.images).insert(
|
||||||
if (f.image != null) {
|
f.image!.copyWith(accountFile: sql.Value(dbAccountFile.rowId)));
|
||||||
await db.into(db.images).insert(
|
}
|
||||||
f.image!.copyWith(accountFile: sql.Value(dbAccountFile.rowId)));
|
if (f.trash != null) {
|
||||||
}
|
await db
|
||||||
if (f.trash != null) {
|
.into(db.trashes)
|
||||||
await db
|
.insert(f.trash!.copyWith(file: sql.Value(rowId)));
|
||||||
.into(db.trashes)
|
}
|
||||||
.insert(f.trash!.copyWith(file: sql.Value(rowId)));
|
_onRowCached(rowId, f, dir);
|
||||||
}
|
}));
|
||||||
_onRowCached(rowId, f, dir);
|
|
||||||
}),
|
|
||||||
eagerError: true,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onRowCached(int rowId, sql.CompleteFileCompanion dbFile, File? dir) {
|
void _onRowCached(int rowId, sql.CompleteFileCompanion dbFile, File? dir) {
|
||||||
|
|
Loading…
Reference in a new issue