chore: bump line length to 120 (#20191)

This commit is contained in:
shenlong
2025-07-25 08:07:22 +05:30
committed by GitHub
parent 977c9b96ba
commit ad65e9011a
517 changed files with 4520 additions and 9514 deletions

View File

@@ -78,11 +78,8 @@ class AssetService {
/// required. Returns `true` if there were any changes.
Future<bool> refreshRemoteAssets() async {
final syncedUserIds = await _etagRepository.getAllIds();
final List<UserDto> syncedUsers = syncedUserIds.isEmpty
? []
: (await _isarUserRepository.getByUserIds(syncedUserIds))
.nonNulls
.toList();
final List<UserDto> syncedUsers =
syncedUserIds.isEmpty ? [] : (await _isarUserRepository.getByUserIds(syncedUserIds)).nonNulls.toList();
final Stopwatch sw = Stopwatch()..start();
final bool changes = await _syncService.syncRemoteAssetsToDb(
users: syncedUsers,
@@ -94,8 +91,10 @@ class AssetService {
}
/// Returns `(null, null)` if changes are invalid -> requires full sync
Future<(List<Asset>? toUpsert, List<String>? toDelete)>
_getRemoteAssetChanges(List<UserDto> users, DateTime since) async {
Future<(List<Asset>? toUpsert, List<String>? toDelete)> _getRemoteAssetChanges(
List<UserDto> users,
DateTime since,
) async {
final dto = AssetDeltaSyncDto(
updatedAfter: since,
userIds: users.map((e) => e.id).toList(),
@@ -112,8 +111,7 @@ class AssetService {
String remoteId,
) async {
try {
final AssetResponseDto? dto =
await _apiService.assetsApi.getAssetInfo(remoteId);
final AssetResponseDto? dto = await _apiService.assetsApi.getAssetInfo(remoteId);
return dto?.people;
} catch (error, stack) {
@@ -142,8 +140,7 @@ class AssetService {
userId: user.id,
);
log.fine("Requesting $chunkSize assets from $lastId");
final List<AssetResponseDto>? assets =
await _apiService.syncApi.getFullSyncForUser(dto);
final List<AssetResponseDto>? assets = await _apiService.syncApi.getFullSyncForUser(dto);
if (assets == null) return null;
log.fine(
"Received ${assets.length} assets from ${assets.firstOrNull?.id} to ${assets.lastOrNull?.id}",
@@ -172,8 +169,7 @@ class AssetService {
a.exifInfo = newExif;
if (newExif != a.exifInfo) {
if (a.isInDb) {
await _assetRepository
.transaction(() => _assetRepository.update(a));
await _assetRepository.transaction(() => _assetRepository.update(a));
} else {
debugPrint("[loadExif] parameter Asset is not from DB!");
}
@@ -230,16 +226,13 @@ class AssetService {
await updateAssets(
assets,
UpdateAssetDto(
visibility:
isArchived ? AssetVisibility.archive : AssetVisibility.timeline,
visibility: isArchived ? AssetVisibility.archive : AssetVisibility.timeline,
),
);
for (var element in assets) {
element.isArchived = isArchived;
element.visibility = isArchived
? AssetVisibilityEnum.archive
: AssetVisibilityEnum.timeline;
element.visibility = isArchived ? AssetVisibilityEnum.archive : AssetVisibilityEnum.timeline;
}
await _syncService.upsertAssetsWithExif(assets);
@@ -263,8 +256,7 @@ class AssetService {
for (var element in assets) {
element.fileCreatedAt = DateTime.parse(updatedDt);
element.exifInfo = element.exifInfo
?.copyWith(dateTimeOriginal: DateTime.parse(updatedDt));
element.exifInfo = element.exifInfo?.copyWith(dateTimeOriginal: DateTime.parse(updatedDt));
}
await _syncService.upsertAssetsWithExif(assets);
@@ -307,10 +299,8 @@ class AssetService {
Future<void> syncUploadedAssetToAlbums() async {
try {
final selectedAlbums =
await _backupRepository.getAllBySelection(BackupSelection.select);
final excludedAlbums =
await _backupRepository.getAllBySelection(BackupSelection.exclude);
final selectedAlbums = await _backupRepository.getAllBySelection(BackupSelection.select);
final excludedAlbums = await _backupRepository.getAllBySelection(BackupSelection.exclude);
final candidates = await _backupService.buildUploadCandidates(
selectedAlbums,
@@ -375,8 +365,7 @@ class AssetService {
var exifInfo = await _exifInfoRepository.get(localExifId);
if (exifInfo != null) {
await _exifInfoRepository
.update(exifInfo.copyWith(description: description));
await _exifInfoRepository.update(exifInfo.copyWith(description: description));
}
}
}
@@ -429,22 +418,16 @@ class AssetService {
// Delete files from local gallery
final candidates = assets.where((asset) => asset.isLocal);
final deletedIds = await _assetMediaRepository
.deleteAll(candidates.map((asset) => asset.localId!).toList());
final deletedIds = await _assetMediaRepository.deleteAll(candidates.map((asset) => asset.localId!).toList());
// Modify local database by removing the reference to the local assets
if (deletedIds.isNotEmpty) {
// Delete records from local database
final isarIds = assets
.where((asset) => asset.storage == AssetState.local)
.map((asset) => asset.id)
.toList();
final isarIds = assets.where((asset) => asset.storage == AssetState.local).map((asset) => asset.id).toList();
await _assetRepository.deleteByIds(isarIds);
// Modify Merged asset to be remote only
final updatedAssets = assets
.where((asset) => asset.storage == AssetState.merged)
.map((asset) {
final updatedAssets = assets.where((asset) => asset.storage == AssetState.merged).map((asset) {
asset.localId = null;
return asset;
}).toList();
@@ -473,9 +456,7 @@ class AssetService {
/// Update asset info bassed on the deletion type.
final payload = shouldDeletePermanently
? assets
.where((asset) => asset.storage == AssetState.merged)
.map((asset) {
? assets.where((asset) => asset.storage == AssetState.merged).map((asset) {
asset.remoteId = null;
asset.visibility = AssetVisibilityEnum.timeline;
return asset;
@@ -489,10 +470,8 @@ class AssetService {
await _assetRepository.updateAll(payload.toList());
if (shouldDeletePermanently) {
final remoteAssetIds = assets
.where((asset) => asset.storage == AssetState.remote)
.map((asset) => asset.id)
.toList();
final remoteAssetIds =
assets.where((asset) => asset.storage == AssetState.remote).map((asset) => asset.id).toList();
await _assetRepository.deleteByIds(remoteAssetIds);
}
});