Skip to content

Commit

Permalink
feat: clear file cache
Browse files Browse the repository at this point in the history
  • Loading branch information
alextran1502 committed Jan 10, 2025
1 parent 3008c46 commit 1d9d5ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mobile/lib/models/upload/share_intent_attachment.model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ class ShareIntentAttachment {

final double uploadProgress;

final int fileLength;

ShareIntentAttachment({
required this.path,
required this.type,
required this.status,
this.uploadProgress = 0,
this.fileLength = 0,
});

int get id => hash(path);
Expand All @@ -49,7 +52,7 @@ class ShareIntentAttachment {

bool get isVideo => type == ShareIntentAttachmentType.video;

String get fileSize => formatHumanReadableBytes(file.lengthSync(), 2);
String get fileSize => formatHumanReadableBytes(fileLength, 2);

ShareIntentAttachment copyWith({
String? path,
Expand Down
5 changes: 5 additions & 0 deletions mobile/lib/repositories/share_handler.repository.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/interfaces/share_handler.interface.dart';
import 'package:immich_mobile/models/upload/share_intent_attachment.model.dart';
Expand Down Expand Up @@ -43,12 +45,15 @@ class ShareHandlerRepository implements IShareHandlerRepository {
? ShareIntentAttachmentType.image
: ShareIntentAttachmentType.video;

final fileLength = File(attachment.path).lengthSync();

payload.add(
ShareIntentAttachment(
path: attachment.path,
type: type,
status: UploadStatus.enqueued,
uploadProgress: 0.0,
fileLength: fileLength,
),
);
}
Expand Down

0 comments on commit 1d9d5ac

Please sign in to comment.