mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-07 16:07:53 -06:00
Merge pull request #269 from astubenbord/bugfix/files-not-correctly-consumed
Bugfix/files not correctly consumed
This commit is contained in:
@@ -44,6 +44,7 @@ class DocumentUploadCubit extends Cubit<DocumentUploadState> {
|
||||
Iterable<int> tags = const [],
|
||||
DateTime? createdAt,
|
||||
int? asn,
|
||||
void Function(double)? onProgressChanged,
|
||||
}) async {
|
||||
final taskId = await _documentApi.create(
|
||||
bytes,
|
||||
@@ -54,6 +55,7 @@ class DocumentUploadCubit extends Cubit<DocumentUploadState> {
|
||||
tags: tags,
|
||||
createdAt: createdAt,
|
||||
asn: asn,
|
||||
onProgressChanged: onProgressChanged,
|
||||
);
|
||||
if (taskId != null) {
|
||||
_tasksNotifier.listenToTaskChanges(taskId);
|
||||
|
||||
@@ -23,27 +23,28 @@ class ConsumptionChangeNotifier extends ChangeNotifier {
|
||||
}
|
||||
|
||||
/// Creates a local copy of all shared files and reloads all files
|
||||
/// from the user's consumption directory.
|
||||
Future<void> addFiles({
|
||||
/// from the user's consumption directory. Returns the newly added files copied to the consumption directory.
|
||||
Future<List<File>> addFiles({
|
||||
required List<File> files,
|
||||
required String userId,
|
||||
}) async {
|
||||
if (files.isEmpty) {
|
||||
return;
|
||||
return [];
|
||||
}
|
||||
final consumptionDirectory =
|
||||
await FileService.getConsumptionDirectory(userId: userId);
|
||||
final List<File> localFiles = [];
|
||||
for (final file in files) {
|
||||
File localFile;
|
||||
if (file.path.startsWith(consumptionDirectory.path)) {
|
||||
localFile = file;
|
||||
if (!file.path.startsWith(consumptionDirectory.path)) {
|
||||
final localFile = await file
|
||||
.copy(p.join(consumptionDirectory.path, p.basename(file.path)));
|
||||
localFiles.add(localFile);
|
||||
} else {
|
||||
final fileName = p.basename(file.path);
|
||||
localFile = File(p.join(consumptionDirectory.path, fileName));
|
||||
await file.copy(localFile.path);
|
||||
localFiles.add(file);
|
||||
}
|
||||
}
|
||||
return loadFromConsumptionDirectory(userId: userId);
|
||||
await loadFromConsumptionDirectory(userId: userId);
|
||||
return localFiles;
|
||||
}
|
||||
|
||||
/// Marks a file as processed by removing it from the queue and deleting the local copy of the file.
|
||||
|
||||
@@ -141,13 +141,13 @@ class _EventListenerShellState extends State<EventListenerShell>
|
||||
if (files.isNotEmpty) {
|
||||
final userId = context.read<LocalUserAccount>().id;
|
||||
final notifier = context.read<ConsumptionChangeNotifier>();
|
||||
await notifier.addFiles(
|
||||
final addedLocalFiles = await notifier.addFiles(
|
||||
files: files,
|
||||
userId: userId,
|
||||
);
|
||||
consumeLocalFiles(
|
||||
context,
|
||||
files: files,
|
||||
files: addedLocalFiles,
|
||||
userId: userId,
|
||||
exitAppAfterConsumed: true,
|
||||
);
|
||||
|
||||
@@ -4,12 +4,6 @@ import 'package:paperless_mobile/features/sharing/view/consumption_queue_view.da
|
||||
import 'package:paperless_mobile/routes/navigation_keys.dart';
|
||||
import 'package:paperless_mobile/routes/routes.dart';
|
||||
|
||||
part 'upload_queue_route.g.dart';
|
||||
|
||||
@TypedGoRoute<UploadQueueRoute>(
|
||||
path: "/upload-queue",
|
||||
name: R.uploadQueue,
|
||||
)
|
||||
class UploadQueueRoute extends GoRouteData {
|
||||
static final GlobalKey<NavigatorState> $parentNavigatorKey =
|
||||
outerShellNavigatorKey;
|
||||
|
||||
@@ -20,6 +20,7 @@ import 'package:paperless_mobile/routes/typed/branches/inbox_route.dart';
|
||||
import 'package:paperless_mobile/routes/typed/branches/labels_route.dart';
|
||||
import 'package:paperless_mobile/routes/typed/branches/landing_route.dart';
|
||||
import 'package:paperless_mobile/routes/typed/branches/scanner_route.dart';
|
||||
import 'package:paperless_mobile/routes/typed/branches/upload_queue_route.dart';
|
||||
import 'package:paperless_mobile/routes/typed/shells/scaffold_shell_route.dart';
|
||||
import 'package:paperless_mobile/routes/typed/top_level/settings_route.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -34,6 +35,10 @@ part 'authenticated_route.g.dart';
|
||||
path: "/settings",
|
||||
name: R.settings,
|
||||
),
|
||||
TypedGoRoute<UploadQueueRoute>(
|
||||
path: "/upload-queue",
|
||||
name: R.uploadQueue,
|
||||
),
|
||||
TypedStatefulShellRoute<ScaffoldShellRoute>(
|
||||
branches: [
|
||||
TypedStatefulShellBranch<LandingBranch>(
|
||||
|
||||
@@ -14,6 +14,7 @@ abstract class PaperlessDocumentsApi {
|
||||
int? correspondent,
|
||||
Iterable<int> tags = const [],
|
||||
int? asn,
|
||||
void Function(double progress)? onProgressChanged,
|
||||
});
|
||||
Future<DocumentModel> update(DocumentModel doc);
|
||||
Future<int> findNextAsn();
|
||||
|
||||
Reference in New Issue
Block a user