fix: Sync leaving left over temp files (#73)

Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
PartyDonut 2024-10-25 18:58:44 +02:00 committed by GitHub
parent c5e39db9ec
commit 8d15e319d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 644 additions and 406 deletions

View file

@ -28,7 +28,7 @@ enum HomeBanner {
String label(BuildContext context) => switch (this) {
HomeBanner.hide => context.localized.hide,
HomeBanner.carousel => context.localized.homeBannerCarousel,
HomeBanner.banner => context.localized.homeBannerBanner,
HomeBanner.banner => context.localized.homeBannerSlideshow,
};
}

View file

@ -28,6 +28,7 @@ part 'i_synced_item.g.dart';
class ISyncedItem {
String? userId;
String id;
bool syncing;
String? sortName;
String? parentId;
String? path;
@ -42,6 +43,7 @@ class ISyncedItem {
ISyncedItem({
this.userId,
required this.id,
required this.syncing,
this.sortName,
this.parentId,
this.path,
@ -59,6 +61,7 @@ class ISyncedItem {
return ISyncedItem(
id: syncedItem.id,
parentId: syncedItem.parentId,
syncing: syncedItem.syncing,
userId: syncedItem.userId,
path: syncedItem.path?.replaceAll(path ?? "", '').substring(1),
fileSize: syncedItem.fileSize,

File diff suppressed because it is too large Load diff

View file

@ -20,6 +20,7 @@ import 'package:fladder/models/items/trick_play_model.dart';
import 'package:fladder/models/syncing/i_synced_item.dart';
import 'package:fladder/providers/sync/sync_provider_helpers.dart';
import 'package:fladder/providers/sync_provider.dart';
import 'package:fladder/util/localization_helper.dart';
part 'sync_item.freezed.dart';
@ -29,6 +30,7 @@ class SyncedItem with _$SyncedItem {
factory SyncedItem({
required String id,
@Default(false) bool syncing,
String? parentId,
required String userId,
String? path,
@ -72,7 +74,7 @@ class SyncedItem with _$SyncedItem {
_ => SyncStatus.partially,
};
String? get taskId => null;
String? get taskId => task?.taskId;
bool get childHasTask => false;
@ -126,6 +128,7 @@ class SyncedItem with _$SyncedItem {
parentId: isarSyncedItem.parentId,
userId: isarSyncedItem.userId ?? "",
sortName: isarSyncedItem.sortName,
syncing: isarSyncedItem.syncing,
path: joinAll([savePath, isarSyncedItem.path ?? ""]),
fileSize: isarSyncedItem.fileSize,
videoFileName: isarSyncedItem.videoFileName,
@ -155,21 +158,25 @@ class SyncedItem with _$SyncedItem {
enum SyncStatus {
complete(
"Synced",
Color.fromARGB(255, 141, 214, 58),
IconsaxOutline.tick_circle,
),
partially(
"Partially",
Color.fromARGB(255, 221, 135, 23),
IconsaxOutline.more_circle,
),
;
const SyncStatus(this.label, this.color, this.icon);
const SyncStatus(this.color, this.icon);
final Color color;
final String label;
String label(BuildContext context) {
return switch (this) {
SyncStatus.partially => context.localized.syncStatusPartially,
SyncStatus.complete => context.localized.syncStatusSynced,
};
}
final IconData icon;
}
@ -183,14 +190,14 @@ extension StatusExtension on TaskStatus {
TaskStatus.paused => Colors.orangeAccent,
};
String get name => switch (this) {
TaskStatus.enqueued => 'Enqueued',
TaskStatus.running => 'Running',
TaskStatus.complete => 'Complete',
TaskStatus.notFound => 'Not Found',
TaskStatus.failed => 'Failed',
TaskStatus.canceled => 'Canceled',
TaskStatus.waitingToRetry => 'Waiting To Retry',
TaskStatus.paused => 'Paused',
String name(BuildContext context) => switch (this) {
TaskStatus.enqueued => context.localized.syncStatusEnqueued,
TaskStatus.running => context.localized.syncStatusRunning,
TaskStatus.complete => context.localized.syncStatusComplete,
TaskStatus.notFound => context.localized.syncStatusNotFound,
TaskStatus.failed => context.localized.syncStatusFailed,
TaskStatus.canceled => context.localized.syncStatusCanceled,
TaskStatus.waitingToRetry => context.localized.syncStatusWaitingToRetry,
TaskStatus.paused => context.localized.syncStatusPaused,
};
}

View file

@ -17,6 +17,7 @@ final _privateConstructorUsedError = UnsupportedError(
/// @nodoc
mixin _$SyncedItem {
String get id => throw _privateConstructorUsedError;
bool get syncing => throw _privateConstructorUsedError;
String? get parentId => throw _privateConstructorUsedError;
String get userId => throw _privateConstructorUsedError;
String? get path => throw _privateConstructorUsedError;
@ -48,6 +49,7 @@ abstract class $SyncedItemCopyWith<$Res> {
@useResult
$Res call(
{String id,
bool syncing,
String? parentId,
String userId,
String? path,
@ -82,6 +84,7 @@ class _$SyncedItemCopyWithImpl<$Res, $Val extends SyncedItem>
@override
$Res call({
Object? id = null,
Object? syncing = null,
Object? parentId = freezed,
Object? userId = null,
Object? path = freezed,
@ -101,6 +104,10 @@ class _$SyncedItemCopyWithImpl<$Res, $Val extends SyncedItem>
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
syncing: null == syncing
? _value.syncing
: syncing // ignore: cast_nullable_to_non_nullable
as bool,
parentId: freezed == parentId
? _value.parentId
: parentId // ignore: cast_nullable_to_non_nullable
@ -195,6 +202,7 @@ abstract class _$$SyncItemImplCopyWith<$Res>
@useResult
$Res call(
{String id,
bool syncing,
String? parentId,
String userId,
String? path,
@ -229,6 +237,7 @@ class __$$SyncItemImplCopyWithImpl<$Res>
@override
$Res call({
Object? id = null,
Object? syncing = null,
Object? parentId = freezed,
Object? userId = null,
Object? path = freezed,
@ -248,6 +257,10 @@ class __$$SyncItemImplCopyWithImpl<$Res>
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
syncing: null == syncing
? _value.syncing
: syncing // ignore: cast_nullable_to_non_nullable
as bool,
parentId: freezed == parentId
? _value.parentId
: parentId // ignore: cast_nullable_to_non_nullable
@ -309,6 +322,7 @@ class __$$SyncItemImplCopyWithImpl<$Res>
class _$SyncItemImpl extends _SyncItem {
_$SyncItemImpl(
{required this.id,
this.syncing = false,
this.parentId,
required this.userId,
this.path,
@ -329,6 +343,9 @@ class _$SyncItemImpl extends _SyncItem {
@override
final String id;
@override
@JsonKey()
final bool syncing;
@override
final String? parentId;
@override
final String userId;
@ -373,7 +390,7 @@ class _$SyncItemImpl extends _SyncItem {
@override
String toString() {
return 'SyncedItem(id: $id, parentId: $parentId, userId: $userId, path: $path, markedForDelete: $markedForDelete, sortName: $sortName, fileSize: $fileSize, videoFileName: $videoFileName, introOutSkipModel: $introOutSkipModel, fTrickPlayModel: $fTrickPlayModel, fImages: $fImages, fChapters: $fChapters, subtitles: $subtitles, userData: $userData)';
return 'SyncedItem(id: $id, syncing: $syncing, parentId: $parentId, userId: $userId, path: $path, markedForDelete: $markedForDelete, sortName: $sortName, fileSize: $fileSize, videoFileName: $videoFileName, introOutSkipModel: $introOutSkipModel, fTrickPlayModel: $fTrickPlayModel, fImages: $fImages, fChapters: $fChapters, subtitles: $subtitles, userData: $userData)';
}
@override
@ -382,6 +399,7 @@ class _$SyncItemImpl extends _SyncItem {
(other.runtimeType == runtimeType &&
other is _$SyncItemImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.syncing, syncing) || other.syncing == syncing) &&
(identical(other.parentId, parentId) ||
other.parentId == parentId) &&
(identical(other.userId, userId) || other.userId == userId) &&
@ -411,6 +429,7 @@ class _$SyncItemImpl extends _SyncItem {
int get hashCode => Object.hash(
runtimeType,
id,
syncing,
parentId,
userId,
path,
@ -437,6 +456,7 @@ class _$SyncItemImpl extends _SyncItem {
abstract class _SyncItem extends SyncedItem {
factory _SyncItem(
{required final String id,
final bool syncing,
final String? parentId,
required final String userId,
final String? path,
@ -455,6 +475,8 @@ abstract class _SyncItem extends SyncedItem {
@override
String get id;
@override
bool get syncing;
@override
String? get parentId;
@override
String get userId;